User tests: Successful: Unsuccessful:
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.
$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.
Before:
<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 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 .
<field
name="id"
type="checkbox"
label="Test value 0 in Checkbox!!!"
default="0" />
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
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.
Before:
<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 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.
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.
I added a description of the PR header .
This pull request has automatically rebased to 4.2-dev.
This pull requests has been automatically converted to the PSR-12 coding standard.
Labels |
Added:
?
|
Labels |
Added:
?
Removed: ? |
Labels |
Added:
?
Maintainers Checked
Removed: ? |
This pull request has been automatically rebased to 4.3-dev.
@HLeithner Is it possible to transfer this PR to Joomla 5 ?
This is a bug, and can go to 4.x, just need to be tested
Labels |
Added:
bug
PR-4.3-dev
?
Removed: ? ? |
I have tested this item
I have tested this item
HTML supports only string value, so no boolean values.
You cannot do <input type="checkbox" value="false">
and expect it will be a boolean, it will be a string false
. The same for Joomla XML fields.
so only 1 or 0
so only 1 or 0
You are right, this will be enough for all use cases.
@bembelimen Please confirm this PR
This pull request has been automatically rebased to 4.4-dev.
@HLeithner
And when will this PR be merged to v5?
Title |
|
Thanks for your pull request. Please add a proper test instruction, so we can test it.