如何在yii2中编写材料设计单选按钮?
我面临yii2中使用的材料设计单选按钮的问题。 这是“材料设计”单选按钮,工作正常如何在yii2中编写材料设计单选按钮?,yii2,material-design,Yii2,Material Design,我面临yii2中使用的材料设计单选按钮的问题。 这是“材料设计”单选按钮,工作正常 <div class="radio"> <label> <input type="radio" name="q_option" value="Recent advances in MS"> Recent advances in MS </label> </div> 质谱研究进展 但是,当我在yii2框架中编写相同的单选
<div class="radio">
<label>
<input type="radio" name="q_option" value="Recent advances in MS">
Recent advances in MS
</label>
</div>
质谱研究进展
但是,当我在yii2框架中编写相同的单选按钮时,单选按钮点会消失,变得不可点击
<div class="radio">
<?= $form->field($model, 'q_option')->radio(
['label' => 'Recent advances in MS', 'value' => 'Recent advances in MS']
) ?>
</div>
请引导我。事先非常感谢。也许你指的是单选按钮?单台收音机没有意义
//controller
$model = new Cities();
return $this->render('index', [
'model' => $model,
]);
//view <?php
use yii\bootstrap\ActiveForm;
?>
<?php $form = ActiveForm::begin() ?>
<div class="radio">
<?= $form->field($model, 'city_name')->radio(
['label' => 'Recent advances in MS', 'value' => 'Recent advances in MS']
) ?>
</div>
<?php $form::end() ?>
//控制器
$model=新城市();
返回$this->render('index'[
'model'=>$model,
]);
//看法
工作顺利
您使用$model和表\字段\名称。也许你试过使用单选按钮列表?就像这样:
//view
$model = new Cities();
return $this->render('index', [
'model' => $model,
'array' => Cities::find()->all(),
]);
//controller
<?php
use yii\bootstrap\ActiveForm;
use yii\helpers\ArrayHelper;
?>
<?php $form = ActiveForm::begin() ?>
<?= $form->field($model, 'city_name')
->radioList(ArrayHelper::map($array, 'id', 'city_name')) ?>
<?php $form::end() ?>
//查看
$model=新城市();
返回$this->render('index'[
'model'=>$model,
“array'=>Cities::find()->all(),
]);
//控制器