JForm/getFields: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Method to get the fields in a group.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</no... |
m removing red link to edit, no existant pages |
||
| Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Syntax=== | ===Syntax=== | ||
| Line 93: | Line 93: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Examples=== | ===Examples=== | ||
| Line 108: | Line 108: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
[[Category:Archived pages API16]] | |||
Revision as of 02:52, 14 May 2013
Description
Method to get the fields in a group.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
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;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />