FOF30\Form\Form::loadHeader PHP Method

loadHeader() protected method

Method to load, setup and return a HeaderInterface object based on field data.
Since: 2.0
protected loadHeader ( string $element, string $group = null ) : FOF30\Form\HeaderInterface | boolean
$element string The XML element object representation of the form field.
$group string The optional dot-separated form group path on which to find the field.
return FOF30\Form\HeaderInterface | boolean The HeaderInterface object for the field or boolean false on error.
    protected function loadHeader($element, $group = null)
    {
        // Make sure there is a valid SimpleXMLElement.
        if (!$element instanceof \SimpleXMLElement) {
            return false;
        }
        // Get the field type.
        $type = $element['type'] ? (string) $element['type'] : 'field';
        // Load the JFormField object for the field.
        $field = $this->loadHeaderType($type);
        // If the object could not be loaded, get a text field object.
        if ($field === false) {
            $field = $this->loadHeaderType('field');
        }
        // Setup the HeaderInterface object.
        $field->setForm($this);
        if ($field->setup($element, $group)) {
            return $field;
        } else {
            return false;
        }
    }