Skip to content
Advertisement

How to add different and common classes in radioList() in yii2

This is the chtml of radio-button in one of my update form.

JavaScript

I need to add class names of common(same) and different classes to each radio input. That is it look like in html…

JavaScript

i have classes to add [inputbox(common to all)and inputindex_1-4 to each radios] i’m syntactically confused to add array of classes to this. How to add these classes to this

JavaScript

Advertisement

Answer

You need to configure the item option for the radioList options, you can see the Html::activeRadioList() for details.

The below code should work for you.

JavaScript

Note: to make the first option selected by default, you should set the attribute with the value inside the action. like

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement