Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Joomla CMS [#23882] JForm::getGroup() not properly generating nested group names #587

Merged
merged 2 commits into from

2 participants

@joomla-jenkins
Collaborator

Build triggered by changes to the base.

Unit testing complete. There were 0 failures and 0 errors from 1873 tests and 11092 assertions.
Checkstyle analysis not found.

@joomla-jenkins
Collaborator

Build triggered by changes to the head.

Unit testing complete. There were 0 failures and 0 errors from 1971 tests and 11143 assertions.
Checkstyle analysis reported 199 warnings and 0 errors.

@chdemko chdemko merged commit 7c0a8c3 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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.'
Something went wrong with that request. Please try again.