Fix for subform field: fix default value for "max" and "groupByFieldset"#11158
Fix for subform field: fix default value for "max" and "groupByFieldset"#11158rdeutz merged 1 commit intojoomla:stagingfrom
Conversation
|
I have tested this item ✅ successfully on c599253 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11158. Thanks for creating this field, already using it in an extension. |
|
I have tested this item ✅ successfully on c599253 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11158. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11158. |
|
|
||
| case 'max': | ||
| $this->max = max(1, (int) $value); | ||
| if ($value) |
There was a problem hiding this comment.
I don't understand this check, $value is set and if it is nothing that will be cast to false it will be used for the max(1, whatever) so that doesn't allow to set max = 0 but that was the same before with the difference that max isn't now set at all. I also don't understand why this only for max and not for min.
There was a problem hiding this comment.
the problem here when attribute max="" is not defined (in field xml), and so it always null here,
so in result we got $this->max = 1;
.. if it is nothing that will be cast to false ..
will be cast to zero, and max(1, 0) will return 1 😉
There was a problem hiding this comment.
Can max have negativ values? If not the the max(1, $value) doesn't makes sense, because value is always 1 or greater.
There was a problem hiding this comment.
in case someone do max="-100"
|
Successfully tested. Perfect. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11158. |
Summary of Changes
This fix a default values for "max" and "groupByFieldset" properties, for subform field.
Testing Instructions
Use "Custom HTML" module and add subform field into the module xml:
and create simple form xml in modules/mod_custom/test1.xml:
expected result
You should see the subform inputs, with possibility to add new row.
actuall result
the subform is empty, and you can add only one row