Actions

API16

JForm/getFields

From Joomla! Documentation

< API16:JForm
Revision as of 21:52, 13 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

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 />