FOF30\Form\Header\HeaderBase::setup PHP Method

setup() public method

Method to attach a Form object to the field.
Since: 2.0
public setup ( SimpleXMLElement $element, string $group = null ) : boolean
$element SimpleXMLElement The SimpleXMLElement object representing the tag for the form field object.
$group string The field name group control value. This acts as as an array container for the field. For example if the field has name="foo" and the group value is set to "bar" then the full field name would end up being "bar[foo]".
return boolean True on success.
    public function setup(SimpleXMLElement $element, $group = null)
    {
        // Make sure there is a valid JFormField XML element.
        if ((string) $element->getName() != 'header') {
            return false;
        }
        // Reset the internal fields
        $this->label = null;
        $this->header = null;
        $this->filter = null;
        $this->buttons = null;
        $this->options = null;
        $this->value = null;
        $this->filterSource = null;
        $this->filterFieldName = null;
        // Set the XML element object.
        $this->element = $element;
        // Get some important attributes from the form field element.
        $id = (string) $element['id'];
        $name = (string) $element['name'];
        $filterSource = (string) $element['filter_source'];
        $filterFieldName = (string) $element['searchfieldname'];
        $tdwidth = (string) $element['tdwidth'];
        // Set the field description text.
        $this->description = (string) $element['description'];
        // Set the group of the field.
        $this->group = $group;
        // Set the td width of the field.
        $this->tdwidth = $tdwidth;
        // Set the field name and id.
        $this->fieldname = $this->getFieldName($name);
        $this->name = $this->getName($this->fieldname);
        $this->id = $this->getId($id, $this->fieldname);
        $this->filterSource = $this->getFilterSource($filterSource);
        $this->filterFieldName = $this->getFilterFieldName($filterFieldName);
        // Set the field default value.
        $this->value = $this->getValue();
        // Setup the onlyFilter property
        $onlyFilter = $this->element['onlyFilter'] ? (string) $this->element['onlyFilter'] : false;
        $this->onlyFilter = in_array($onlyFilter, array('yes', 'on', '1', 'true'));
        return true;
    }