API16:JForm/getFields
From Joomla! Documentation
Contents |
Description
Method to get the fields in a group.
Syntax
getFields($group= '_default', $formControl= '_default', $groupControl= '_default')
| Parameter Name | Default Value | Description |
|---|---|---|
| $group | '_default' | $group The form field group. |
| $formControl | '_default' | $formControl The optional form control. Set to false to disable. |
| $groupControl | '_default' | $groupControl The optional group control. Set to false to disable. |
Returns
array Associative array of rendered Form Field object by field name
Defined in
libraries/joomla/form/form.php
Importing
jimport( 'joomla.form.form' );
Source Body
public function getFields($group = '_default', $formControl = '_default', $groupControl = '_default') { $results = array(); // Check the form control. if ($formControl == '_default') { $formControl = $this->_options['array']; } // Check the group control. if ($groupControl == '_default'&& isset($this->_fieldsets[$group])) { $array = $this->_fieldsets[$group]['array']; if ($array === true) { if(isset($this->_fieldsets[$group]['parent'])) { $groupControl = $this->_fieldsets[$group]['parent']; } else { $groupControl = $group; } } else { $groupControl = $array; } } // Set the prefix $prefix = $this->_options['prefix']; // Check if the group exists. if (isset($this->_groups[$group])) { // Get the fields in the group. foreach ($this->_groups[$group] as $name => $node) { // Get the field info. $type = (string)$node->attributes()->type; $value = (isset($this->_data[$group]) && array_key_exists($name, $this->_data[$group]) && ($this->_data[$group][$name] !== null)) ? $this->_data[$group][$name] : $node->attributes()->default; // Load the field. $field = &$this->loadFieldType($type); // If the field could not be loaded, get a text field. if ($field === false) { $field = &$this->loadFieldType('text'); } // Render the field. $results[$name] = $field->render($node, $value, $formControl, $groupControl, $prefix); } } return $results; }
[Edit See Also] SeeAlso:JForm/getFields