Actions

API16

Difference between revisions of "JForm/getField"

From Joomla! Documentation

< API16:JForm
(New page: ===Description=== Method to get a form field. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </s...)
 
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>[[Description:JForm/getField|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JForm/getField}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 101: Line 101:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JForm/getField|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JForm/getField}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 116: Line 116:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Latest revision as of 20:52, 13 May 2013

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 a form field.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

getField($name, $group= '_default', $formControl= '_default', $groupControl= '_default', $value=null)
Parameter Name Default Value Description
$name $name The name of the form field.
$group '_default' $group The group the field is in.
$formControl '_default' $formControl The optional form control. Set to false to disable.
$groupControl '_default' $groupControl The optional group control. Set to false to disable.
$value null $value The optional value to render as the default for the field.

Returns

object Rendered Form Field object

Defined in

libraries/joomla/form/form.php

Importing

jimport( 'joomla.form.form' );

Source Body

public function getField($name, $group = '_default', $formControl = '_default', $groupControl = '_default', $value = null)
{
        // Get the XML node.
        $node = isset($this->_groups[$group][$name]) ? $this->_groups[$group][$name] : null;
 
        // If there is no XML node for the given field name, return false.
        if (empty($node)) {
                return false;
        }
 
        // Load the field type.
        $type   = $node->attributes()->type;
        $field  = & $this->loadFieldType($type);
 
        // If the field could not be loaded, get a text field.
        if ($field === false) {
                $field = & $this->loadFieldType('text');
        }
 
        // Get the value for the form field.
        if ($value === null) {
                $value = (array_key_exists($name, $this->_data[$group]) && ($this->_data[$group][$name] !== null)) ? $this->_data[$group][$name] : (string)$node->attributes()->default;
        }
 
        // 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'];
 
        // Render the field.
        return $field->render($node, $value, $formControl, $groupControl, $prefix);
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />