Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
419db81
Add option to limit field choices selection
AbdiTolesa Sep 18, 2025
131c38a
Refactor function
AbdiTolesa Sep 19, 2025
795be68
Add disable attribute to radio fields based on choice limit setting
AbdiTolesa Sep 19, 2025
bd9f947
Do not check disabled checkbox
AbdiTolesa Sep 25, 2025
191299f
Cover dropdown field for choice limit checks
AbdiTolesa Sep 25, 2025
e4fd076
Do not disable choices in builder
AbdiTolesa Sep 29, 2025
ea2ea27
Try reusing frm_field_input_html to output disabled html att
AbdiTolesa Sep 30, 2025
055c1b7
Hide/Disable field choices that hit max entry based off the form sett…
AbdiTolesa Sep 30, 2025
de943ef
Committing progress
AbdiTolesa Sep 30, 2025
06102a9
Fix some style errors
AbdiTolesa Oct 1, 2025
c6872b7
Revert some changes
AbdiTolesa Oct 3, 2025
fcf9770
Hide/Disable choices based off the new setting
AbdiTolesa Oct 8, 2025
5613edd
Remove extra function param passed to FrmFieldsController::maybe_disa…
AbdiTolesa Oct 8, 2025
4e097eb
Add latest field choice output updates to dropdown field
AbdiTolesa Oct 8, 2025
acb7bd1
Make function and variables more descriptive for choice limit check l…
AbdiTolesa Oct 8, 2025
9a3ff48
Fix merge conflicts
AbdiTolesa Oct 8, 2025
55c4931
Sync js files with master
AbdiTolesa Oct 8, 2025
53f1676
Sync js files with master
AbdiTolesa Oct 8, 2025
5931cad
Sync js files with master
AbdiTolesa Oct 8, 2025
9ac0c74
Move function from Pro to Lite
AbdiTolesa Oct 8, 2025
8bef115
Resolve dependency on Pro
AbdiTolesa Oct 8, 2025
b376cda
Fix workflow errors
AbdiTolesa Oct 14, 2025
da17e00
Reduce PHP logic in view files
AbdiTolesa Oct 14, 2025
b7b357a
Move function that fetches form option into Pro
AbdiTolesa Oct 14, 2025
ad7e2c2
Avoid outputting <select> tag if all choices have hit their limit for…
AbdiTolesa Oct 22, 2025
e367bcf
Move code that should be in Pro to there
AbdiTolesa Oct 22, 2025
3b8a3df
Add choice limit reached validation message to helper function
AbdiTolesa Oct 22, 2025
6d48545
Cover other field types for showing new message
AbdiTolesa Oct 22, 2025
e8aac0c
Change default message for choice limit reached
AbdiTolesa Oct 22, 2025
c497327
Change array_filter calls to foreach
AbdiTolesa Oct 22, 2025
78ad919
Use current() to simplify complicated code
AbdiTolesa Oct 22, 2025
c7709ea
Fix merge conflict
AbdiTolesa Oct 22, 2025
574fd74
Merge branch 'master' into limit_choices_selection_lite_part
AbdiTolesa Oct 22, 2025
05f367a
Fix potential bugs
AbdiTolesa Oct 22, 2025
6020eaf
Fix missing variable warning
AbdiTolesa Oct 22, 2025
6ec1d1c
Fix potential bug
AbdiTolesa Nov 11, 2025
9986575
Add comment to new action
AbdiTolesa Nov 11, 2025
f11b7ac
Merge master
AbdiTolesa Nov 12, 2025
5050456
Add a couple of enhancements
AbdiTolesa Nov 12, 2025
1d7d8e4
Fix limit input element getting selected when it shouldn't
AbdiTolesa Nov 13, 2025
2ad0655
Make sure maxed out options are not reset on entry submit
AbdiTolesa Nov 13, 2025
20976b9
Add a new hook frm_should_echo_disabled_attribute
AbdiTolesa Nov 14, 2025
bf4e6a3
Merge branch 'master' into limit_choices_selection_lite_part
Crabcyborg Nov 17, 2025
3fe4eeb
Tweak label query
Crabcyborg Nov 17, 2025
799de54
Fix issue with other options not getting added
Crabcyborg Nov 17, 2025
8c5c69f
Do some code refactoring
AbdiTolesa Nov 17, 2025
645aada
Merge branch 'limit_choices_selection_lite_part' of https://github.co…
AbdiTolesa Nov 17, 2025
e1e3244
Do some code refactoring
AbdiTolesa Nov 17, 2025
cda61bb
Add filter that allows updating field default validation messages
AbdiTolesa Nov 17, 2025
7c62ffe
Update new filter param comment
AbdiTolesa Nov 17, 2025
0946032
Fix potential condition check bug
AbdiTolesa Nov 17, 2025
db23bfc
Align array arrows
AbdiTolesa Nov 17, 2025
e953057
Add missing function descriptions
AbdiTolesa Nov 18, 2025
471f39b
Move should_hide_field_choice method to FrmFieldsHelper
AbdiTolesa Nov 26, 2025
01de971
Move FrmFieldsController::should_echo_disabled_attribute to FrmFields…
AbdiTolesa Nov 26, 2025
52d85eb
Move more functions and shorten a function param
AbdiTolesa Nov 26, 2025
15b47f6
Fix a potential bug
AbdiTolesa Nov 26, 2025
db58a4e
Delete return type declaration for a filter
AbdiTolesa Nov 26, 2025
c6d5edd
Fix merge conflict
AbdiTolesa Nov 26, 2025
4a385b3
Build files
AbdiTolesa Nov 26, 2025
ae6be8a
Address potential bugs and improve code related to choice limit feature
AbdiTolesa Nov 26, 2025
06418cb
Move more choices limit feature related code to Pro
AbdiTolesa Nov 26, 2025
2ed2690
Move more code from Lite to Pro
AbdiTolesa Nov 26, 2025
50f3d5f
Refactor code to simplify logics in view files
AbdiTolesa Nov 27, 2025
242c12a
Delete code not needed in Lite
AbdiTolesa Nov 27, 2025
c8f792d
Merge branch 'master' into limit_choices_selection_lite_part
AbdiTolesa Nov 28, 2025
d74ef56
Merge branch 'master' into limit_choices_selection_lite_part
AbdiTolesa Nov 28, 2025
bce1dc3
Clean up stubs.php
AbdiTolesa Nov 28, 2025
7b49acb
Add a missing ?? check
AbdiTolesa Nov 28, 2025
994471e
Fix a PHP doc separation check error
AbdiTolesa Nov 28, 2025
dc09bc3
Merge branch 'master' into limit_choices_selection_lite_part
Crabcyborg Dec 3, 2025
9057e3d
Merge branch 'master' into limit_choices_selection_lite_part
Crabcyborg Dec 3, 2025
87f0ec0
Cast to bool
AbdiTolesa Dec 4, 2025
c2786f5
Fix merge conflicts
AbdiTolesa Dec 4, 2025
cc787a3
Cast to bool
AbdiTolesa Dec 4, 2025
e347397
Merge branch 'master' into limit_choices_selection_lite_part
AbdiTolesa Dec 4, 2025
efc359a
Fixed code style with PHP CS Fixer
AbdiTolesa Dec 4, 2025
338cd21
Fixed code style with PHP CS Fixer
AbdiTolesa Dec 4, 2025
fcbca46
Reduce opacity for disabled inputs
AbdiTolesa Dec 4, 2025
7d783ee
Support showing remaining choice entries
AbdiTolesa Dec 22, 2025
cba9039
Support showing remaining choices for image formatted choices
AbdiTolesa Dec 22, 2025
03c62b2
Pass extra param to frm_choice_field_option_label filter
AbdiTolesa Dec 22, 2025
2e899fb
Merge master
AbdiTolesa Dec 22, 2025
6472959
Add missing param needed for showing remaining choice entries
AbdiTolesa Dec 22, 2025
eca4902
Fix code style errors
AbdiTolesa Dec 23, 2025
43b7e71
Simplify and refactor functions
AbdiTolesa Dec 23, 2025
32b0c04
Avoid inline comment
AbdiTolesa Dec 23, 2025
638848b
Add a field setting that allows controlling whether remaining options…
AbdiTolesa Dec 30, 2025
1200b96
Add field settings to customize choice limit messages
AbdiTolesa Dec 31, 2025
b35fe1a
Merge master and rebuild files
AbdiTolesa Dec 31, 2025
21c1222
Merge master and rebuild files
AbdiTolesa Dec 31, 2025
038f926
Fix merge conflicts and merge master
AbdiTolesa Jan 21, 2026
77e0861
Fix remaining merge conflict
AbdiTolesa Jan 21, 2026
4b86627
Fix codestyle issues
AbdiTolesa Jan 21, 2026
5667907
Merge branch 'master' into limit_choices_selection_lite_part
Crabcyborg Jan 21, 2026
b86c871
Drop map files
Crabcyborg Jan 21, 2026
626562e
Reduce repeated code and delete Pro related style
AbdiTolesa Jan 22, 2026
580a932
Merge branch 'limit_choices_selection_lite_part' of https://github.co…
AbdiTolesa Jan 22, 2026
32c41c5
Fix broken PHPCS rule
AbdiTolesa Jan 22, 2026
a240155
Make filter name more generic
AbdiTolesa Jan 23, 2026
c86c146
Move more Pro related to Pro
AbdiTolesa Jan 26, 2026
cd6b75f
Change variable names and fix function description comments
AbdiTolesa Jan 27, 2026
b1361c0
Add missing $ symbol
AbdiTolesa Jan 27, 2026
1fd31a8
Group functions together
AbdiTolesa Jan 27, 2026
a39eb33
Fix merge conflict with master and merge master
AbdiTolesa Jan 27, 2026
6341144
Merge branch 'master' into limit_choices_selection_lite_part
Crabcyborg Jan 27, 2026
a5f8d0b
Use kses echo (merge conflict error)
Crabcyborg Jan 27, 2026
39946a5
Update param type in filter description
AbdiTolesa Jan 27, 2026
14e0f06
Fix static analysis error
AbdiTolesa Jan 27, 2026
75eb854
Try alternative way to reuse echo_dropdown_option
AbdiTolesa Jan 27, 2026
23f215c
Align function params spacing
AbdiTolesa Jan 27, 2026
5ba0a83
Merge branch 'master' into limit_choices_selection_lite_part
Crabcyborg Jan 27, 2026
699093d
Address some comments
AbdiTolesa Jan 27, 2026
1e011ec
Merge branch 'limit_choices_selection_lite_part' of https://github.co…
AbdiTolesa Jan 27, 2026
00c8bed
Add missing variable name from filter params description comment
AbdiTolesa Jan 27, 2026
d382ac5
Merge branch 'master' into limit_choices_selection_lite_part
Crabcyborg Jan 27, 2026
6c64a19
Change function name
AbdiTolesa Jan 27, 2026
d11b8af
Merge branch 'limit_choices_selection_lite_part' of https://github.co…
AbdiTolesa Jan 27, 2026
9537362
Change function name to make it more descriptive
AbdiTolesa Jan 27, 2026
507066a
Update function comment
AbdiTolesa Jan 27, 2026
59e3bc7
Change function name for consistency
AbdiTolesa Jan 28, 2026
478dbfd
Make hook and function names consistent
AbdiTolesa Feb 2, 2026
23abbdc
Make hook name consistent
AbdiTolesa Feb 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions classes/controllers/FrmFieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,29 @@ private static function maybe_define_field_selection_data() {
return self::$field_selection_data;
}

/**
* @since x.x
*
* @param array $field
* @param string $opt_key
*
* @return bool
*/
public static function maybe_disable_option( $field, $opt_key ) {
if ( FrmAppHelper::is_form_builder_page() ) {
return false;
}

/**
* @since x.x
*
* @param bool $disabled
* @param array $field
* @param string $opt_key
*/
return apply_filters( 'frm_choice_limit_reached', false, $field, $opt_key );
}

/**
* Get the list of default value types that can be toggled in the builder.
*
Expand Down
14 changes: 10 additions & 4 deletions classes/views/frm-fields/front-end/checkbox-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
do_action( 'frm_after_checkbox', compact( 'field', 'field_name', 'type' ) );
} elseif ( $field['options'] ) {
$option_index = 0;

$form_options = FrmDb::get_var( 'frm_forms', array( 'id' => $field['form_id'] ), 'options' );
FrmAppHelper::unserialize_or_decode( $form_options );
foreach ( $field['options'] as $opt_key => $opt ) {
if ( isset( $shortcode_atts ) && isset( $shortcode_atts['opt'] ) && $shortcode_atts['opt'] !== $opt_key ) {
$disabled = FrmFieldsController::maybe_disable_option( $field, $opt_key, $form_options );

Check failure on line 22 in classes/views/frm-fields/front-end/checkbox-field.php

View workflow job for this annotation

GitHub Actions / PHPStan

Static method FrmFieldsController::maybe_disable_option() invoked with 3 parameters, 2 required.
if ( FrmProFieldsController::should_hide_field_choice( $disabled, $shortcode_atts, $opt_key, $form_options ) ) {

Check failure on line 23 in classes/views/frm-fields/front-end/checkbox-field.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to static method should_hide_field_choice() on an unknown class FrmProFieldsController.
continue;
}

$field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
$opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );

Expand Down Expand Up @@ -65,10 +66,15 @@
}

?><input type="checkbox" name="<?php echo esc_attr( $field_name ); ?>[<?php echo esc_attr( $other_opt ? $opt_key : '' ); ?>]" id="<?php echo esc_attr( $html_id ); ?>-<?php echo esc_attr( $opt_key ); ?>" value="<?php echo esc_attr( $field_val ); ?>"<?php
echo $checked . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

do_action( 'frm_field_input_html', $field );

if ( $disabled ) {
echo ' disabled="disabled" data-max-reached="1"';
} else {
echo $checked . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

if ( 0 === $option_index && FrmField::is_required( $field ) ) {
echo ' aria-required="true" ';
}
Expand Down
6 changes: 5 additions & 1 deletion classes/views/frm-fields/front-end/dropdown-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@
if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
$option_params['class'] = 'frm_other_trigger';
}

$disabled = FrmFieldsController::maybe_disable_option( $field, $opt_key );
if ( $disabled ) {
$option_params['disabled'] = 'disabled';
$selected = false;
}
FrmHtmlHelper::echo_dropdown_option( $opt, (bool) $selected, $option_params );
unset( $option_params );
}//end foreach
Expand Down
8 changes: 5 additions & 3 deletions classes/views/frm-fields/front-end/radio-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
$type = $field['type'];
do_action( 'frm_after_checkbox', compact( 'field', 'field_name', 'type' ) );
} elseif ( is_array( $field['options'] ) ) {
$form_options = FrmDb::get_var( 'frm_forms', array( 'id' => $field['form_id'] ), 'options' );
FrmAppHelper::unserialize_or_decode( $form_options );
foreach ( $field['options'] as $opt_key => $opt ) {
if ( isset( $shortcode_atts ) && isset( $shortcode_atts['opt'] ) && ( $shortcode_atts['opt'] !== $opt_key ) ) {
$disabled = FrmFieldsController::maybe_disable_option( $field, $opt_key, $form_options );

Check failure on line 21 in classes/views/frm-fields/front-end/radio-field.php

View workflow job for this annotation

GitHub Actions / PHPStan

Static method FrmFieldsController::maybe_disable_option() invoked with 3 parameters, 2 required.
if ( FrmProFieldsController::should_hide_field_choice( $disabled, $shortcode_atts, $opt_key, $form_options ) ) {

Check failure on line 22 in classes/views/frm-fields/front-end/radio-field.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to static method should_hide_field_choice() on an unknown class FrmProFieldsController.
continue;
}

$field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
$opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );

Expand Down Expand Up @@ -53,8 +55,8 @@
?>
<input type="radio" name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ); ?>" value="<?php echo esc_attr( $field_val ); ?>"
<?php
echo $checked . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
do_action( 'frm_field_input_html', $field );
echo $disabled ? ' disabled="disabled" ' : $checked . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>/><?php

if ( ! isset( $shortcode_atts ) || ! isset( $shortcode_atts['label'] ) || $shortcode_atts['label'] ) {
Expand Down
613 changes: 612 additions & 1 deletion css/admin/frm-settings-components.css

Large diffs are not rendered by default.

Loading
Loading