Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #587 from chdemko/23882

Joomla CMS [#23882] JForm::getGroup() not properly generating nested group names
  • Loading branch information...
commit 7c0a8c3a43c2ceba3b2709e1774700cb8c67471b 2 parents 4cbccff + 07921f3
@chdemko chdemko authored
View
5 libraries/joomla/form/form.php
@@ -526,6 +526,11 @@ public function getGroup($group, $nested = false)
// Build the result array from the found field elements.
foreach ($elements as $element)
{
+ // Get the field groups for the element.
+ $attrs = $element->xpath('ancestor::fields[@name]/@name');
+ $groups = array_map('strval', $attrs ? $attrs : array());
+ $group = implode('.', $groups);
+
// If the field is successfully loaded add it to the result array.
if ($field = $this->loadField($element, $group))
{
View
6 tests/suite/joomla/form/JFormTest.php
@@ -977,6 +977,12 @@ public function testGetGroup()
);
$this->assertThat(
+ array_keys($form->getGroup('level1', true)),
+ $this->equalTo(array('level1_field1', 'level1_level2_field2')),
+ 'Line:'.__LINE__.' The level1 group should have 2 nested field elements.'
+ );
+
+ $this->assertThat(
count($form->getGroup('level1.level2')),
$this->equalTo(1),
'Line:'.__LINE__.' The level2 group should have 1 field element.'
Please sign in to comment.
Something went wrong with that request. Please try again.