Skip to content
This repository

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

Merged
merged 2 commits into from over 2 years ago

2 participants

Christophe Demko Jools
Jools
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.

Jools
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.

Christophe Demko chdemko merged commit 7c0a8c3 into from January 03, 2012
Christophe Demko chdemko closed this January 03, 2012
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.
5  libraries/joomla/form/form.php
@@ -526,6 +526,11 @@ public function getGroup($group, $nested = false)
526 526
 		// Build the result array from the found field elements.
527 527
 		foreach ($elements as $element)
528 528
 		{
  529
+			// Get the field groups for the element.
  530
+			$attrs	= $element->xpath('ancestor::fields[@name]/@name');
  531
+			$groups	= array_map('strval', $attrs ? $attrs : array());
  532
+			$group	= implode('.', $groups);
  533
+
529 534
 			// If the field is successfully loaded add it to the result array.
530 535
 			if ($field = $this->loadField($element, $group))
531 536
 			{
6  tests/suite/joomla/form/JFormTest.php
@@ -977,6 +977,12 @@ public function testGetGroup()
977 977
 		);
978 978
 
979 979
 		$this->assertThat(
  980
+			array_keys($form->getGroup('level1', true)),
  981
+			$this->equalTo(array('level1_field1', 'level1_level2_field2')),
  982
+			'Line:'.__LINE__.' The level1 group should have 2 nested field elements.'
  983
+		);
  984
+
  985
+		$this->assertThat(
980 986
 			count($form->getGroup('level1.level2')),
981 987
 			$this->equalTo(1),
982 988
 			'Line:'.__LINE__.' The level2 group should have 1 field element.'
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.