JForm/getFields
From Joomla! Documentation
< API16:JForm
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Method to get the fields in a group.
<! removed transcluded page call, red link never existed >
Syntax[edit]
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[edit]
array Associative array of rendered Form Field object by field name
Defined in[edit]
libraries/joomla/form/form.php
Importing[edit]
jimport( 'joomla.form.form' );
Source Body[edit]
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;
}
<! removed transcluded page call, red link never existed >
Examples[edit]
Code Examples[edit]