Back to Form class

Method getAttribute

public mixed
getAttribute
(mixed $name, mixed $default = null)
Returns the value of an attribute of the form itself
Parameters
  • string $name Name of the attribute to get
  • mixed $default Optional value to return if attribute not found
Returns
  • mixed Value of the attribute / default
Since
  • 3.2
Class: Form
Project: Joomla

Method getAttribute - Source code

/**
 * Returns the value of an attribute of the form itself
 *
 * @param   string  $name     Name of the attribute to get
 * @param   mixed   $default  Optional value to return if attribute not found
 *
 * @return  mixed             Value of the attribute / default
 *
 * @since   3.2
 */
public function getAttribute($name, $default = null)
{
    if ($this->xml instanceof \SimpleXMLElement) {
        $value = $this->xml->attributes()->{$name};
        if ($value !== null) {
            return (string) $value;
        }
    }
    return $default;
}