public \Joomla\CMS\Form\FormField[]
getGroup
(mixed $group, mixed $nested = false)
/**
* Method to get an array of FormField objects in a given field group by name.
*
* @param string $group The dot-separated form group path for which to get the form fields.
* @param boolean $nested True to also include fields in nested groups that are inside of the
* group for which to find fields.
*
* @return FormField[] The array of FormField objects in the field group.
*
* @since 1.7.0
*/
public function getGroup($group, $nested = false)
{
$fields = [];
// Get all of the field elements in the field group.
$elements = $this->findFieldsByGroup($group, $nested);
// If no field elements were found return empty.
if (empty($elements)) {
return $fields;
}
// 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 ?: []);
$group = implode('.', $groups);
// If the field is successfully loaded add it to the result array.
if ($field = $this->loadField($element, $group)) {
$fields[$field->id] = $field;
}
}
return $fields;
}