-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.2] Add support ID with 0 for value CheckboxField.php #37174
[5.2] Add support ID with 0 for value CheckboxField.php #37174
Conversation
Thanks for your pull request. Please add a proper test instruction, so we can test it. |
I can't find the Checkbox field test file. I'm new to writing tests. Previously, I wrote only 2 amendments to Joomla tests. Please tell me where I can find the Checkbox field test. |
Please provide steps to reproduce the issue in order to test the PR. |
$field = JFormHelper::loadFieldType('сheckbox', true);
$field->setup(simplexml_load_string('<field type="check" default="0" name="id" />', 0);
echo $field->getInput(); The result can only be seen in the generated HTML. Because of this limitation of fields, we can't check in any other way, except to look for values in HTML. <div class="form-check form-check-inline">
<input
type="checkbox"
name="check"
id="id"
value="1"
>
</div> After: <div class="form-check form-check-inline">
<input
type="checkbox"
name="check"
id="id"
value="0"
>
</div> Here you need to search for the string |
When you have a look at #37349, there you can see some test instructions how it should be. If the tester has to edit some files, write that in the testing instructions. That's not a problem. |
You are right, I understood my mistake. I described a new correction indicating the perimers on the principle: as it was before, and how it will become in the future. |
This pull request has automatically rebased to 4.2-dev. |
This pull requests has been automatically converted to the PSR-12 coding standard. |
This pull request has been automatically rebased to 5.2-dev. |
Wow.. 2.5 years have passed. |
Co-authored-by: Tuan Pham Ngoc <[email protected]>
Suggestion has been implemented
I have tested this item ✅ successfully on 76a3db2 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37174. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37174. |
Thank you! |
This amendment concerns to use this field to pass ID as an argument. If we use this field not in an XML file but in a dynamic table of fields. In each row of the table, we use the Checkbox to select a row number or select an ID in the list. After activating these checkboxes, we mark which of the parameter lists with which ID we have activated.
I believe that the original code implied the use of checkboxes as just a parameter in the static configuration of the settings page, not to select an ID, but simply to select certain settings.
Therefore, such a subtlety as using the value '0' as a value was not taken into account.
My change does not violate compatibility and does not violate the default settings.
And of course it would be stupid on the part of external developers to use the value '0' of the attribute to get an activated checkbox.
Because the value '0' is interpreted as an empty value and we get an active checkbox. In this way, it is stupid to mark activity using unreadable, this is a stupid approach to activate the checkbox.
Therefore, I suggest using the value '0' as the value for ID selection.
The result can only be seen in the generated HTML. Because of this limitation of fields, we can't check in any other way, except to look for values in HTML.
Before:
After:
Here you need to search for the string
value ="0"
with tests, otherwise no way.In the Checkbox field, any default value is rendering correctly except for 0.
The default value of 0 is rendering as 1.
This fix can be checked in any module add writing this XML example to the module’s XML configuration file and after check this value in the F12 panel in the browser .