How do you make a raidoList required?

I am trying to make a radioList required in Yii2 and it keeps failing validation.

It keeps saying that a value isn’t selected when one is. (I’ve removed the rule and the value is sent)

I know Yii1 has this issue (reuse of ID’s that didn’t jive with the jquery) and I had to do work around.

Is there a fix to this; if so can someone please post it?

My code I have is pretty basic standard stuff.

['status', 'required', 'message' => '{attribute} can\'t be blank'],


$form->field($model, 'status')->radioList([

 'test' => 'test'



The only thing I have managed to get to work is adding an onclick event but if a defualt value is set in the controller then it won’t recognize it failing the required client side validation unless you physically click the radio option.

one that works for the validation but doesn’t work on default value being set.


$form->field($model, 'class')->radioList($items,[

'onclick' => "$(this).val($('input:radio:checked').val());"



anyone know how to do this?

You must set it as required in the model rules

Please read the post. Raido and Check don’t work with the “required” rule.