The
foreach ($elements as $element)
{
...
}
loop within findField should have the loop variable renamed to (eg) $el, otherwise it can end up being returned as the function return value.
Eg for
$jform = new JForm('testform');
$jform->load(<<<'XML'
<form>
<fields name="A">
<field name="fielda"/>
<fields name="B">
<field name="fieldab"/>
</fields>
</fields>
</form>
XML
);
$field = $jform->findField('fieldab','A'); // should return false, but returns whole <fields name="A"> element.
print ($field? $field->asXML()."\n": "false")."\n";
And then for
$jform->load(<<<'XML'
<form>
<fields name="A">
<field name="fieldab"/>
</fields>
</form>
XML
,true); // should add a new <field name="fieldab"/> element to the <fields name="A"> element, instead deletes the whole original <fields name="A"> element and adds the <field> at the "top" level.
print $jform->getxml()->asXML();
David
See commented code above
See commented code above
Status | New | ⇒ | Confirmed |
Status | Confirmed | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-08-22 17:39:44 |
Closed_By | ⇒ | brianteeman |
I confirm this issue exists.
But...., the given code won't execute from outside
JForm
asfindField
is a protected method. UsinggetField
will still return false because field setup fails atlibraries/joomla/form/form.php:1823
aslibraries/joomla/form/field.php:557
returns false.@dr138 Please send a PR.