src/View/Helper/FormHelper.php
public function switcher($fieldName, array $options = [])
    {
        $input = parent::checkbox($fieldName, $options);

        if ($this->getConfig('materializeCss', false) === false) {
            return $input;
        }

        $options += [
            'before' => __d('backend', 'Off'),
            'after'  => __d('backend', 'On')
        ];

        $title = (Arr::key('title', $options)) ? $options['title'] : $fieldName;

        if (!empty($title)) {
            $title = $this->Html->div('switch-title', $title);
        }

        $content = $this->formatTemplate(__FUNCTION__, [
            'input'  => $input,
            'title'  => $title,
            'after'  => $options['after'],
            'before' => $options['before'],
            'lever'  => '<span class="lever"></span>'
        ]);

        return $content;
    }
public function switcher($fieldName, array $options = [])
    {
        $input = parent::checkbox($fieldName, $options);

        if ($this->getConfig('materializeCss', false) === false) {
            return $input;
        }

        $options += [
            'before' => __d('backend', 'Off'),
            'after'  => __d('backend', 'On')
        ];

        $title = (Arr::key('title', $options)) ? $options['title'] : $fieldName;

        if (!empty($title)) {
            $title = $this->Html->div('switch-title', $title);
        }

        $content = $this->formatTemplate(__FUNCTION__, [
            'input'  => $input,
            'title'  => $title,
            'after'  => $options['after'],
            'before' => $options['before'],
            'lever'  => '<span class="lever"></span>'
        ]);

        return $content;
    }
public function switcher ( $ fieldName , array $ options = [ ] ) { $ input = parent :: checkbox ( $ fieldName , $ options ) ; if ( $ this -> getConfig ( 'materializeCss' , false ) === false ) { return $ input ; } $ options += [ 'before' => __d ( 'backend' , 'Off' ) , 'after' => __d ( 'backend' , 'On' ) ] ; $ title = ( Arr :: key ( 'title' , $ options ) ) ? $ options [ 'title' ] : $ fieldName ; if ( ! empty ( $ title ) ) { $ title = $ this -> Html -> div ( 'switch-title' , $ title ) ; } $ content = $ this -> formatTemplate ( __FUNCTION__ , [ 'input' => $ input , 'title' => $ title , 'after' => $ options [ 'after' ] , 'before' => $ options [ 'before' ] , 'lever' => '<span class="lever"></span>' ] ) ; return $ content ; }
Form switcher.

@param   string $fieldName
@param   array $options
@return  string
Form switcher .