API16

Difference between revisions of "JForm/getFields"

From Joomla! Documentation

< API16:JForm
(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 (preparing for archive only)
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
Method to get the fields in a group.
 
Method to get the fields in a group.
  
<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[Description:JForm/getFields|Edit Descripton]]<nowiki>]</nowiki>
 
</span>
 
  
{{Description:JForm/getFields}}
+
 
 +
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 92: Line 90:
 
</source>
 
</source>
  
<span class="editsection" style="font-size:76%;">
+
 
<nowiki>[</nowiki>[[SeeAlso:JForm/getFields|Edit See Also]]<nowiki>]</nowiki>
+
<! removed transcluded page call, red link never existed >
</span>
 
{{SeeAlso:JForm/getFields}}
 
  
 
===Examples===
 
===Examples===
<CodeExamplesForm />
+
=== Code Examples ===
 
<dpl>
 
<dpl>
 
  noresultsheader=\n
 
  noresultsheader=\n
 
  category=getFields
 
  category=getFields
 
  category=JForm
 
  category=JForm
  category=CodeExample
+
  namespace=CodeExample
 
  category=MethodExample
 
  category=MethodExample
 
  include=*
 
  include=*
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Latest revision as of 20:41, 24 March 2017

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]