diff --git a/classes/helpers/FrmFieldsHelper.php b/classes/helpers/FrmFieldsHelper.php
index c87e81cf49..f18eb72a30 100644
--- a/classes/helpers/FrmFieldsHelper.php
+++ b/classes/helpers/FrmFieldsHelper.php
@@ -474,6 +474,14 @@ public static function get_error_msg( $field, $error ) {
),
);
+ /**
+ * @since x.x
+ *
+ * @param array $defaults
+ * @param array|object $field
+ */
+ $defaults = apply_filters( 'frm_default_field_validation_messages', $defaults, $field );
+
$msg = FrmField::get_option( $field, $error );
$msg = $msg ? $msg : $defaults[ $error ]['part'];
$msg = do_shortcode( $msg );
@@ -2799,4 +2807,85 @@ private static function get_ai_generate_options_button_class() {
)
);
}
+
+ /**
+ * Checks if the field choice should be hidden due to choice limit being reached.
+ *
+ * @since x.x
+ *
+ * @param string $choice_key
+ * @param array $field
+ *
+ * @return bool
+ */
+ public static function should_hide_field_choice( $choice_key, $field ) {
+ /**
+ * @since x.x
+ *
+ * @param bool $hide_field_choice
+ * @param string $choice_key
+ * @param array $field
+ */
+ return (bool) apply_filters( 'frm_hide_field_choice', false, $choice_key, $field );
+ }
+
+ /**
+ * @since x.x
+ *
+ * @param array $field
+ *
+ * @return bool
+ */
+ public static function should_skip_rendering_choices_for_field( $field ) {
+ /**
+ * @since x.x
+ *
+ * @param bool $skip_rendering_options_for_field
+ * @param array $field
+ */
+ return (bool) apply_filters( 'frm_should_skip_rendering_choices_for_field', false, $field );
+ }
+
+ /**
+ * Determine if 'disabled' attribute should be echoed in a field choice's HTML.
+ *
+ * @since x.x
+ *
+ * @param string $choice_key
+ * @param bool $is_selected_choice
+ * @param array $field
+ *
+ * @return bool
+ */
+ public static function should_disable_choice( $choice_key, $is_selected_choice, $field ) {
+ /**
+ * @since x.x
+ *
+ * @param bool $echo_disabled_attribute
+ * @param string $choice_key
+ * @param bool $is_selected_choice
+ * @param array $field
+ */
+ return (bool) apply_filters( 'frm_disable_choice', false, $choice_key, $is_selected_choice, $field );
+ }
+
+ /**
+ * @since x.x
+ *
+ * @param array $field
+ * @param string $choice_key
+ *
+ * @return void
+ */
+ public static function after_choice_input( $field, $choice_key ) {
+ /**
+ * Allows adding content after checkbox, radio button, or dropdown fields.
+ *
+ * @since x.x
+ *
+ * @param array $field The field data.
+ * @param string $choice_key The option key.
+ */
+ do_action( 'frm_after_choice_input', $field, $choice_key );
+ }
}
diff --git a/classes/views/frm-fields/back-end/field-options.php b/classes/views/frm-fields/back-end/field-options.php
index 3757f89a9a..8efd9bd687 100644
--- a/classes/views/frm-fields/back-end/field-options.php
+++ b/classes/views/frm-fields/back-end/field-options.php
@@ -5,6 +5,8 @@
$field_option_count = is_array( $args['field']['options'] ) ? count( $args['field']['options'] ) : 0;
?>
+
+
@@ -24,8 +26,6 @@
-
-
show_single_option( $args ); ?>
diff --git a/classes/views/frm-fields/back-end/settings.php b/classes/views/frm-fields/back-end/settings.php
index 04ec1ce115..e8b6f24ada 100644
--- a/classes/views/frm-fields/back-end/settings.php
+++ b/classes/views/frm-fields/back-end/settings.php
@@ -529,6 +529,14 @@
diff --git a/classes/views/frm-fields/front-end/checkbox-field.php b/classes/views/frm-fields/front-end/checkbox-field.php
index f2ba9b2a37..0c8c701d3a 100644
--- a/classes/views/frm-fields/front-end/checkbox-field.php
+++ b/classes/views/frm-fields/front-end/checkbox-field.php
@@ -15,6 +15,10 @@
$type = $field['type'];
do_action( 'frm_after_checkbox', compact( 'field', 'field_name', 'type' ) );
} elseif ( $field['options'] ) {
+ if ( FrmFieldsHelper::should_skip_rendering_choices_for_field( $field ) ) {
+ return;
+ }
+
$option_index = 0;
foreach ( $field['options'] as $opt_key => $opt ) {
@@ -22,6 +26,10 @@
continue;
}
+ if ( FrmFieldsHelper::should_hide_field_choice( $opt_key, $field ) ) {
+ continue;
+ }
+
$field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
$opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );
@@ -31,9 +39,9 @@
* @since 5.0.04
*
* @param string $label Label HTML.
- * @param array $args The arguments. Contains `field`.
+ * @param array $args The arguments. Contains `field` and `field_val`.
*/
- $label = apply_filters( 'frm_choice_field_option_label', $opt, compact( 'field' ) );
+ $label = apply_filters( 'frm_choice_field_option_label', $opt, compact( 'field', 'field_val' ) );
// init.
$checked = '';
@@ -49,26 +57,34 @@
$other_opt = false;
$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key', 'field_val' ), $other_opt, $checked );
+ $should_echo_disabled_att = FrmFieldsHelper::should_disable_choice( $opt_key, $checked, $field );
?>
$html_id . '-' . $opt_key,
);
- if ( $read_only ) {
+ if ( $read_only || $should_echo_disabled_att ) {
$label_attributes['class'] = 'frm-label-disabled';
}
+
?>