I
I
Ivan Komarov2017-04-05 11:36:58
css
Ivan Komarov, 2017-04-05 11:36:58

YII2. Radio Buttons: How to change the style for the selected option?

Usually I wrote in css:
input[type=radio]:checked + label:before { ... }
And in HTML:

<input id="decline" type="radio" name="action" value="Decline">
<label for="decline">Decline</label>

And everything was great.
But in YII2 it doesn't work like this.
To generate a radio selector, I use the following code
<?=$form->field($model, 'checkingAction')->inline()->radioList($text[weekly_check_options], [
            'onchange' => new \yii\web\JsExpression($onChangeJs)]
        )->label(false);?>

And in HTML I get:
<label class="radio-inline"><input type="radio" name="Task_to_user[checkingAction]" value="2"> Decline</label>

Any ideas how to style your checked option with this syntax?
Or maybe there are other ways to generate radio selector via Active Form?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question