<?php $model->test=($model->test)?:1?>

<?= $form->field($model, 'test',[

   'options'=>['class' => 'form-group form-md-radios'],

    'template' => '{label}<div class="col-md-9 md-radio-inline">{input}</div>{hint}{error}', 

])->radioList([1=>Yii::t('common','has'),0=>Yii::t('common','not')],

[

    'item' => function($index, $label, $name, $checked, $value) {

        $checked=$checked?"checked":"";

        $return = '<div class="md-radio">';

        $return .= '<input type="radio" id="' . $name . $value . '" name="' . $name . '" value="' . $value . '" class="md-radiobtn"  '.$checked.'>';

        $return .= '<label for="' . $name . $value . '">

                    <span></span>

                    <span class="check"></span>

                    <span class="box"></span>' . ucwords($label) . '</label>';

        $return .= '</div>';

        return $return;

    }

]) ?>

上一篇:Yii2学习笔记十六:图片上传(转载)

下一篇:Yii2学习笔记十八:Ueditor百度编辑器(转载)