widgets/SwitchButton.php
public function renderButtons()
    {
        list($name, $id) = $this->resolveNameID();
        $buttons   = array();
        $checked   = $this->hasModel() ? (!$this->model->{$this->attribute}) : true;
        $buttons[] = \CHtml::radioButton($name, $checked, array('id' => $id . '_on', 'value' => 1));
        $buttons[] = \CHtml::label($this->offLabel, $id . '_on');
        $checked   = $checked ? false : true;
        $buttons[] = \CHtml::radioButton($name, $checked, array('id' => $id . '_off', 'value' => 1));
        $buttons[] = \CHtml::label($this->onLabel, $id . '_off');
        $buttons[] = '<span></span>';

        return \CHtml::tag('div', $this->htmlOptions, implode("\n", $buttons));
    }
public function renderButtons()
    {
        list($name, $id) = $this->resolveNameID();
        $buttons   = array();
        $checked   = $this->hasModel() ? (!$this->model->{$this->attribute}) : true;
        $buttons[] = \CHtml::radioButton($name, $checked, array('id' => $id . '_on', 'value' => 1));
        $buttons[] = \CHtml::label($this->offLabel, $id . '_on');
        $checked   = $checked ? false : true;
        $buttons[] = \CHtml::radioButton($name, $checked, array('id' => $id . '_off', 'value' => 1));
        $buttons[] = \CHtml::label($this->onLabel, $id . '_off');
        $buttons[] = '<span></span>';

        return \CHtml::tag('div', $this->htmlOptions, implode("\n", $buttons));
    }
public function renderButtons ( ) { list ( $ name , $ id ) = $ this -> resolveNameID ( ) ; $ buttons = array ( ) ; $ checked = $ this -> hasModel ( ) ? ( ! $ this -> model -> { $ this -> attribute } ) : true ; $ buttons [ ] = \ CHtml :: radioButton ( $ name , $ checked , array ( 'id' => $ id . '_on' , 'value' => 1 ) ) ; $ buttons [ ] = \ CHtml :: label ( $ this -> offLabel , $ id . '_on' ) ; $ checked = $ checked ? false : true ; $ buttons [ ] = \ CHtml :: radioButton ( $ name , $ checked , array ( 'id' => $ id . '_off' , 'value' => 1 ) ) ; $ buttons [ ] = \ CHtml :: label ( $ this -> onLabel , $ id . '_off' ) ; $ buttons [ ] = '<span></span>' ; return \ CHtml :: tag ( 'div' , $ this -> htmlOptions , implode ( "\n" , $ buttons ) ) ; }
Returns the formatted button
@return string the resulting HTML
Returns the formatted button