User tests: Successful: Unsuccessful:
As I have got a "loot positive" feedbacks there I have decided to make this pull
So, here is revert #2617, and fix for #7316 and #7372, and alternative fix for #2617
Currently JForm
do not check when the Browser do not submit the value for some inputs, due specific behavior of these input types (checkbox(es), multiple select) or because field was removed by User by editing HTML.
This patch force JForm::filter()
to check whether submitted data has all inputs.
test
Apply patch.
Add to the templates/protostar/templateDetails.xml
next fields (after <fieldset name="advanced">
):
<field type="checkbox" name="checkbox" label="Checkbox" />
<field type="checkboxes" name="checkboxes" label="Checkboxes" >
<option value="1">1</option>
<option value="2">2</option>
<option value="text">text</option>
</field>
<field type="list" name="list" label="List" multiple="true" >
<option value="1">1</option>
<option value="2">2</option>
<option value="text">text</option>
</field>
Then open libraries/joomla/form/form.php
and in line 250 (before "return") add:
$d = $output->toArray();
echo '<pre>';
var_dump($d['params']);
echo '</pre>';
exit;
Then go to edit Protostar template parameters, leave all custom fields empty and push save.
Before patch
You get:
array (size=8)
'checkboxes' => array()
'list' => array()
'templateColor' => string '#0088cc' (length=7)
'templateBackgroundColor' => string '#f4f6f7' (length=7)
'logoFile' => string '' (length=0)
'sitetitle' => string '' (length=0)
'sitedescription' => string '' (length=0)
'googleFont' => string '1' (length=1)
'googleFontName' => string 'Open+Sans' (length=9)
'fluidContainer' => string '0' (length=1)
Means custom fields was not submitted and so, not available. (Joomla <= 3.4.1)
Upd (Joomla >= 3.4.2): Here single checkbox
is missed, and multiple fields has array
value that is wrong, because it is cause the validation problem, and the problem with loading the default value when use Registry
.
After patch
You should get:
array (size=11)
'checkbox' => null
'checkboxes' => null
'list' => null
'templateColor' => string '#0088cc' (length=7)
'templateBackgroundColor' => string '#f4f6f7' (length=7)
'logoFile' => string '' (length=0)
'sitetitle' => string '' (length=0)
'sitedescription' => string '' (length=0)
'googleFont' => string '1' (length=1)
'googleFontName' => string 'Open+Sans' (length=9)
'fluidContainer' => string '0' (length=1)
Now all fields available in data, and unchecked checkboxes has "empty" values.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Category | ⇒ | Libraries |
Hi Fedir, in 3.4.3:
BEFORE PATCH:
$a = $this->params->get('checkboxes', 'CHECKBOX');// VALUE is Array(), should be CHECKBOX
$b = $this->params->get('list', 'LIST');// VALUE is Array(), should be LIST
This is wrong as we have talked about.
AFTER PATCH
$a = $this->params->get('checkboxes', 'CHECKBOX');// VALUE is CHECKBOX
$b = $this->params->get('list', 'LIST');// VALUE is LIST
So for me, it seems everything is working OK with this patch. I have tested other parameters (text, file) and seems they are not influenced by this patch and they behave like expected.
Thank you, Jan
@bembelimen as far as I know browser do not send "empty array" for the "multiple select" list .. in this case browser send nothing at all, for this field
the problem since Joomla 3.4.2 .... after pull #2617 JForm::filter()
force array
value for these fields, that is wrong, and that why you can get the problem with multiselect validation
Status | Pending | ⇒ | Ready to Commit |
RTC based on testing
Labels |
Added:
?
|
Milestone |
Added: |
Milestone |
Added: |
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-09-01 18:26:29 |
Closed_By | ⇒ | Kubik-Rubik |
Labels |
Removed:
?
|
yes I will
@bembelimen @PhocaCz please test