macgyer\yii2materializecss\widgets\form\SwitchButton::init PHP Method

init() public method

Initialize the widget.
public init ( )
    public function init()
    {
        parent::init();
        Html::addCssClass($this->options, ['container' => 'switch']);
        if ($this->hasModel()) {
            if (!isset($this->inputOptions['name'])) {
                $this->inputOptions['name'] = Html::getInputName($this->model, $this->attribute);
            }
            if (!isset($this->inputOptions['id'])) {
                $this->inputOptions['id'] = Html::getInputId($this->model, $this->attribute);
            }
        } else {
            $this->inputOptions['name'] = $this->name;
        }
        $this->inputOptions['uncheck'] = isset($this->uncheck) ? $this->uncheck : is_null($this->uncheck) ? null : '0';
        $this->inputOptions['value'] = isset($this->value) ? $this->value : '1';
    }