teraßyte Posted March 27, 2022 Posted March 27, 2022 (edited) Here's the steps to reproduce the issue: 1) Create a simple form with the following code: $form = new \IPS\Helpers\Form; $form->add( new \IPS\Helpers\Form\CheckboxSet( 'my_chekboxset_field', ( \IPS\Settings::i()->my_chekboxset_field ? ( \IPS\Settings::i()->my_chekboxset_field == '*' ? '*' : explode( ',', \IPS\Settings::i()->my_chekboxset_field ) ) : '' ), FALSE, array( 'options' => \IPS\Member\Group::groups(), 'multiple' => TRUE, 'parse' => 'normal', 'unlimited' => '*', 'unlimitedLang' => 'all_groups', 'impliedUnlimited' => FALSE ) ) ); 2) Now disable the setting (or Customize and deselect all options) and save the form; this will save the setting as an empty string in the database. 3) When the form is reloaded the setting is fully enabled (all Customize options selected). At this point I would actually expect the YesNo setting to be off (all Customize options deselected) but the code instead falls back to the unlimited value if the setting is an empty string (it should do that only if the field has the same * value). By removing the unlimited option the form field acts as expected with no options selected on page load. The only way I found to make it work is to specifically set the value to NULL when the setting (or the options array for customize) is empty which makes it NOT fall back on the unlimited value: if ( empty($values['my_chekboxset_field']) ) { $values['my_chekboxset_field'] = NULL; } === There are also a couple of other related issues I noticed: The same issue with the unlimited value happens also when using a Select helper form The unlimitedLang option for the CheckboxSet form helper doesn't work because the template applications/core/dev/html/global/forms/checkboxset.phtml (line 49) is hardcoded to use all instead of the passed $unlimitedLang template value: <a class="ipsCursor_pointer" data-action="checkboxsetAll">{lang="all"}</a> / <a class="ipsCursor_pointer" data-action="checkboxsetNone">{lang="none"}</a> Edited March 27, 2022 by teraßyte
teraßyte Posted March 27, 2022 Author Posted March 27, 2022 Btw, the conf_default column for the setting in my DB is set to the unlimited value * (asterisk). I made a new similar field (this one defaults to an empty string though) and the setting works just fine like that (well, it simply falls back to the default empty string value).
Recommended Posts