? Success

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
8 Jul 2015

As I have got a "loot positive" feedbacks there I have decided to make this pull :sweat_smile:

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.

avatar Fedik Fedik - open - 8 Jul 2015
avatar Fedik Fedik - change - 8 Jul 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 8 Jul 2015
Labels Added: ?
avatar Fedik
Fedik - comment - 8 Jul 2015

@bembelimen @PhocaCz please test

avatar zero-24 zero-24 - change - 8 Jul 2015
Category Libraries
avatar PhocaCz
PhocaCz - comment - 8 Jul 2015

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

avatar zero-24 zero-24 - alter_testresult - 9 Jul 2015 - PhocaCz: Tested successfully
avatar bembelimen
bembelimen - comment - 10 Jul 2015

Hello,

regarding to #7372
If you have a multiple required field (e.g. a multiple select list) and the form sends an empty array, your patch does still not trigger the "field is required" error (=> see my patch)

avatar Fedik
Fedik - comment - 10 Jul 2015

@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 :wink:

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

avatar JonasAtZwetschke JonasAtZwetschke - test_item - 20 Jul 2015 - Tested successfully
avatar BeniSt BeniSt - test_item - 21 Jul 2015 - Tested successfully
avatar zero-24 zero-24 - change - 4 Aug 2015
Status Pending Ready to Commit
avatar zero-24
zero-24 - comment - 4 Aug 2015

RTC based on testing


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7381.

avatar joomla-cms-bot joomla-cms-bot - change - 4 Aug 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 25 Aug 2015
Milestone Added:
avatar zero-24 zero-24 - change - 25 Aug 2015
Milestone Added:
avatar Kubik-Rubik Kubik-Rubik - change - 1 Sep 2015
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2015-09-01 18:26:29
Closed_By Kubik-Rubik
avatar Kubik-Rubik Kubik-Rubik - close - 1 Sep 2015
avatar joomla-cms-bot joomla-cms-bot - close - 1 Sep 2015
avatar Kubik-Rubik Kubik-Rubik - reference | a394bda - 1 Sep 15
avatar Kubik-Rubik Kubik-Rubik - merge - 1 Sep 2015
avatar Kubik-Rubik Kubik-Rubik - close - 1 Sep 2015
avatar Kubik-Rubik
Kubik-Rubik - comment - 1 Sep 2015

Thank you @Fedik! Merged.

avatar joomla-cms-bot joomla-cms-bot - change - 1 Sep 2015
Labels Removed: ?
avatar Fedik Fedik - head_ref_deleted - 2 Sep 2015
avatar Bakual
Bakual - comment - 2 Sep 2015

@Fedik This PR broke the installation of Joomla. Can you check?

avatar Fedik
Fedik - comment - 2 Sep 2015

yes I will

Add a Comment

Login with GitHub to post a comment