API16

API16:JForm/setValue

From Joomla! Documentation

Revision as of 22:51, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Method to set the value of a field. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowi...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Method to set the value of a field.

[Edit Descripton]

Template:Description:JForm/setValue

Syntax

setValue($field, $value, $group= '_default')
Parameter Name Default Value Description
$field $field The field to set.
$value $value The value to set the field to.
$group '_default' $group The group the field is in.

Returns

boolean True if field exists, false otherwise.

Defined in

libraries/joomla/form/form.php

Importing

jimport( 'joomla.form.form' );

Source Body

public function setValue($field, $value, $group = '_default')
{
        // Set the field if it exists.
        if (isset($this->_groups[$group][$field]) && is_object($this->_groups[$group][$field])) {
                $this->_data[$group][$field] = $value;
                return true;
        } else {
                return false;
        }
}

[Edit See Also] Template:SeeAlso:JForm/setValue

Examples

<CodeExamplesForm />

Wrong description

Above syntax is wrong and doesn't work in Joomla 1.6.1.

The correct is:

$this->form->setValue($field, $group , $value);

Bornakke 15:59, 13 April 2011 (CDT) Edit comment