From 31f3ab64ec323b1b30abcb139e7b71c6097ae3b5 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Thu, 29 Oct 2026 11:10:29 -0300 Subject: [PATCH 1/5] feat(fields): add hooks for dropdown option groups Add frm_dropdown_field_before_option and frm_dropdown_field_after_options around the dropdown options, the frm_bulk_edit_options filter on parsed Bulk Edit Options lines, and the frm_bulk_edit_before_option_line JS filter used when building the Bulk Edit text. Pro uses these to render and edit option groups. Co-Authored-By: Claude Opus 5.5 --- classes/controllers/FrmFieldsController.php | 10 ++++++++++ .../frm-fields/front-end/dropdown-field.php | 19 +++++++++++++++++++ js/formidable_admin.js | 2 +- js/src/admin/admin.js | 9 +++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/classes/controllers/FrmFieldsController.php b/classes/controllers/FrmFieldsController.php index 626164196e..714023dfd5 100644 --- a/classes/controllers/FrmFieldsController.php +++ b/classes/controllers/FrmFieldsController.php @@ -537,6 +537,16 @@ public static function import_options() { } } + /** + * Filters the options parsed from the Bulk Edit Options text before they are displayed. + * + * @since x.x + * + * @param array $opts One item per line, either a string or an array with 'label' and 'value'. + * @param array $field The field the options belong to. + */ + $opts = apply_filters( 'frm_bulk_edit_options', $opts, $field ); + // Keep other options after bulk update. if ( ! empty( $field['field_options']['other'] ) ) { $other_array = array(); diff --git a/classes/views/frm-fields/front-end/dropdown-field.php b/classes/views/frm-fields/front-end/dropdown-field.php index e89396707b..2ef0b6c013 100644 --- a/classes/views/frm-fields/front-end/dropdown-field.php +++ b/classes/views/frm-fields/front-end/dropdown-field.php @@ -85,6 +85,16 @@ $option_params['disabled'] = 'disabled'; } + /** + * Fires before each option in a dropdown field is printed. + * + * @since x.x + * + * @param array $field The field being displayed. + * @param int|string $opt_key The key of the option about to be printed. + */ + do_action( 'frm_dropdown_field_before_option', $field, $opt_key ); + echo '