Habari\FormControl::add_template_class PHP Method

add_template_class() public method

Add one or more CSS classes to this control's template
public add_template_class ( string $target, array | string $classes ) : FormControl
$target string The name of the targeted element in the control template
$classes array | string An array or a string of classes to add to this control's template
return FormControl $this
    public function add_template_class($target, $classes)
    {
        if (!isset($this->settings['template_attributes'])) {
            $this->settings['template_attributes'] = array();
        }
        if (!isset($this->settings['template_attributes'][$target])) {
            $this->settings['template_attributes'][$target] = array();
        }
        if (!isset($this->settings['template_attributes'][$target]['class'])) {
            $this->settings['template_attributes'][$target]['class'] = array();
        }
        $this->settings['template_attributes'][$target]['class'] = array_merge(Utils::single_array($this->settings['template_attributes'][$target]['class']), explode(' ', $classes));
        return $this;
    }