ActiveForm Radio ButtonValidation

Hi there. I am new to Yii. Please Bear with me.

I have searched the forums and also through many Google search pages before making this post.


Validation of the radio Button in active form. I’ve attached the screenshot of the problem.

Essentially, it says "… cannot be blank" even when the radio button is selected.

I am using the Yii2 Advanced Template and ActiveForm



Most of the solutions I found are complicated and for yii 1.1.

How do I validate radio/checkbox and other non-text fields?

Thank you for your help!

Welcome to the forum.

I see nothing strange in your posted code. It should work as expected.

What about $model? Is it really the model that you want it to be?

Sorry for the late reply! I solved it by removing the Trim rule in the model. Thanks!