? Success
Referenced as Duplicate of: # 8452

User tests: Successful: Unsuccessful:

avatar izharaazmi
izharaazmi
11 Nov 2015

Currently it converts all nested objects to array silently (see #3737). Some components relying on old behavior (prior to #3737) may expect object type values for the form fields.
This fix does not process the entire nested structure, instead converts only binding levels to array for internal iterations.

avatar izharaazmi izharaazmi - open - 11 Nov 2015
avatar izharaazmi izharaazmi - change - 11 Nov 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 11 Nov 2015
Labels Added: ?
avatar izharaazmi
izharaazmi - comment - 11 Nov 2015

Use the following code to test:

$xml   = '<form>
            <fields name="level1">
                <fields name="level2">
                    <field name="field1" type="text"/>
                    <field name="field2" type="custom"/>
                    <field name="field3" type="custom"/>
                </fields>
            </fields>
        </form>';

$array = array(
            'level1' => array(
                'level2' => array(
                    'field1' => 'field_value',
                    'field2' => array(
                        'a' ,
                        (object) array('b' => 'B' ,'c' => 'C')
                    ),
                    'field3' => (object) array('a' => 'AA' ,'b' => 'BB')
                )
            )
        );

$data  = Joomla\Utilities\ArrayHelper::toObject($array, 'JObject');
$form  = JForm::getInstance('JFormBindTest', $xml);
$form->bind($data);

echo '<pre>';
print_r($data);
print_r($form);
echo '</pre>';

@vietvh Please check this out and cross test against #3737 (comment)

avatar zero-24
zero-24 - comment - 11 Nov 2015

Can This ne tested somehow? E.g. With a extension that don't work bevor but after that patch?

avatar izharaazmi
izharaazmi - comment - 11 Nov 2015

@zero-24 I am not particularly seeing any such extension, however the referenced PR (#3737) has changed the behavior of JForm bind method in this regard, as a result of which few extensions are likely to break.
That issue is fixed here along with the fix made by #3737. Therefore both the test cases should pass now.

The comment #3737 (comment) by @vietvh mentions some issue regarding previous change.

avatar vietvh
vietvh - comment - 12 Nov 2015

@izharaazmi : the new change in this pull request worked fine with my code. At least from what I tested.

The common form that I've seen from core Joomla components and many 3rd extensions is using this structure:

  1. form > fieldset > field
  2. form > fields > fieldset > field

From your use case, you are nesting 2 same tags (form > fields > fields > field). This is the first time I see this therefore I am a little bit curious, why did you have to use that instead of the common pattern 1 and 2 above?

avatar izharaazmi
izharaazmi - comment - 12 Nov 2015

@vietvh You are right about the patterns used commonly. But that is not restricted by Joomla, and the nesting like fields > fields > fields > ... at any level creates the form elements at the same depth.

I'd also like to mention that fieldset does not affect the nesting of input fields in the output.

Therefore to replicate the nesting issue in minimal code I just used such nesting. Hope this answers your query.

avatar izharaazmi
izharaazmi - comment - 12 Nov 2015

@vietvh If you tested the PR with your code and the given test case. Please update the test result here.

avatar vietvh
vietvh - comment - 17 Nov 2015

Worked fine for me, this patch fixes the following:

  1. It does not generate PHP warning (as mentioned in #3737)
  2. It does not break the current JForm behavior (like #3737 did)
  3. It allows nested form fields as in test case above.
avatar izharaazmi
izharaazmi - comment - 18 Nov 2015

@Kubik-Rubik The PR for the extended issue reported after merge in #3737 is here. Kindly have a look at your convenience.

avatar roland-d roland-d - alter_testresult - 21 Nov 2015 - vietvh: Tested successfully
avatar roland-d roland-d - test_item - 21 Nov 2015 - Tested successfully
avatar roland-d
roland-d - comment - 21 Nov 2015

I have tested this item :white_check_mark: successfully on 64bc802

I have tested this successfully. The tags were not working before, they are working now.


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

avatar roland-d roland-d - change - 21 Nov 2015
Status Pending Ready to Commit
avatar roland-d
roland-d - comment - 21 Nov 2015

Setting to RTC as we have 2 successful tests.


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

avatar joomla-cms-bot joomla-cms-bot - change - 21 Nov 2015
Labels Added: ?
avatar rdeutz rdeutz - change - 21 Nov 2015
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2015-11-21 18:57:42
Closed_By rdeutz
avatar rdeutz rdeutz - close - 21 Nov 2015
avatar joomla-cms-bot joomla-cms-bot - close - 21 Nov 2015
avatar joomla-cms-bot joomla-cms-bot - change - 21 Nov 2015
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment