Back to Form class

Method bind

public bool
bind
(mixed $data)
Method to bind data to the form.
Parameters
  • mixed $data An array or object of data to bind to the form.
Returns
  • bool True on success.
Since
  • 1.7.0
Class: Form
Project: Joomla

Method bind - Source code

/**
 * Method to bind data to the form.
 *
 * @param   mixed  $data  An array or object of data to bind to the form.
 *
 * @return  boolean  True on success.
 *
 * @since   1.7.0
 */
public function bind($data)
{
    // Make sure there is a valid Form XML document.
    if (!$this->xml instanceof \SimpleXMLElement) {
        throw new \UnexpectedValueException(sprintf('%s::%s `xml` is not an instance of SimpleXMLElement', \get_class($this), __METHOD__));
    }
    // The data must be an object or array.
    if (!\is_object($data) && !\is_array($data)) {
        return false;
    }
    $this->bindLevel(null, $data);
    return true;
}