Answer the question
In order to leave comments, you need to log in
How to create a form with radio buttons in yii2?
It is necessary to implement something similar to an interactive test in yii2. According to the found example, I created the following:
in views:
<?php $form = ActiveForm::begin(); ?>
<?= $form-> field ($modeltest, 'yes')->radio () ?>
<?= $form-> field ($modeltest, 'no')->radio () ?>
<div class="form-group">
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
class TestForm extends Model
{
public $yes;
public $no;
public function rules () {
return [
[['yes', 'no'], 'required'],
];
}
}
$modeltest = new TestForm;
return $this->render('main-confirm2', ['model' => $model,
'test' => $testsql->sql('test01', 1),
'modeltest' => $modeltest,
]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question