ActiveField.php
public function switcher($options = [], $flags = null)
    {
        parent::checkbox($options, false);
        if ($flags === null) {
            $label = Html::encode($this->model->getAttributeLabel(Html::getAttributeName($this->attribute)));
            $labelParts = explode(',', $label);
            $flags = count($labelParts) >= 2 ? $labelParts : null;
        }
        if ($flags) {
            Html::removeCssClass($this->options, 'input-field');
            Html::addCssClass($this->options, 'switch');
            $labelContent = $flags[0] . $this->parts['{input}'] . Html::tag('span', '', ['class' => 'lever']) . $flags[1];
            $this->parts['{input}'] = Html::label($labelContent, Html::getInputId($this->model, $this->attribute));
        }
        return $this;
    }
public function switcher($options = [], $flags = null)
    {
        parent::checkbox($options, false);
        if ($flags === null) {
            $label = Html::encode($this->model->getAttributeLabel(Html::getAttributeName($this->attribute)));
            $labelParts = explode(',', $label);
            $flags = count($labelParts) >= 2 ? $labelParts : null;
        }
        if ($flags) {
            Html::removeCssClass($this->options, 'input-field');
            Html::addCssClass($this->options, 'switch');
            $labelContent = $flags[0] . $this->parts['{input}'] . Html::tag('span', '', ['class' => 'lever']) . $flags[1];
            $this->parts['{input}'] = Html::label($labelContent, Html::getInputId($this->model, $this->attribute));
        }
        return $this;
    }
public function switcher ( $ options = [ ] , $ flags = null ) { parent :: checkbox ( $ options , false ) ; if ( $ flags === null ) { $ label = Html :: encode ( $ this -> model -> getAttributeLabel ( Html :: getAttributeName ( $ this -> attribute ) ) ) ; $ labelParts = explode ( ',' , $ label ) ; $ flags = count ( $ labelParts ) >= 2 ? $ labelParts : null ; } if ( $ flags ) { Html :: removeCssClass ( $ this -> options , 'input-field' ) ; Html :: addCssClass ( $ this -> options , 'switch' ) ; $ labelContent = $ flags [ 0 ] . $ this -> parts [ '{input}' ] . Html :: tag ( 'span' , '' , [ 'class' => 'lever' ] ) . $ flags [ 1 ] ; $ this -> parts [ '{input}' ] = Html :: label ( $ labelContent , Html :: getInputId ( $ this -> model , $ this -> attribute ) ) ; } return $ this ; }
Renders switcher
@see http://materializecss.com/forms.html#switches
@param array $options
@param array $flags
@return $this
Renders switcher