Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

inputs with :as => :radio_buttons are being skipped in validation #20

vitalim opened this Issue Mar 3, 2013 · 16 comments


None yet

vitalim commented Mar 3, 2013

In a form I'm building using ClientSideValidations + SimpleForm (with the gem plugin) the client side validation works for all fields except the :radio_buttons. The HTML that is produced for this group is similar to the other working ones:




Yet when the submit button is clicked, all the other inputs get the 'error' class but the radio_buttons input does not. If I remove the :as => :radio_buttons, the client side validations works just fine.

Any idea what is causing this? Thanks!


bcardarella commented Mar 3, 2013

Radio buttons were filtered out of the parent ClientSideValidations gem but were always intended to be put back in with ClientSideValidations-SimpleForm and ClientSideValidations-Formtastic.

They are being filtered because in the regular Rails form builder there is no concept of wrapping the radio buttons in a single group so it is not possible to render the errors in a similar manner as the server will render.

However, with Formtastic and SimpleForm it does render as a group so the render function can attach to this wrapper element. For some reason I never got around to putting this functionality back in. I should prioritize it.

Thank you for bringing it to my attention.

daliusg commented Mar 13, 2013

Is there a hotfix for this?

I'm having this same problem. is there any hot fix for that?

matenia commented May 21, 2013

+1 for hotfix .. having a hard time implementing a reliable solution in client_side_validations-simple_form

Bug in local presense validator. $().val() from check-box return value, without considering that it must be checked.

hau commented Jul 20, 2013


@bcardarella - Any chance on providing some guidance on what needs to be do to implement this fix?


manishie commented Feb 8, 2015

Here's a quick hack around the problem. It seems as though even though radio buttons are not processed, the gem is still sending data about the radio button validations to the browser. Type 'window.ClientSideValidations.forms' into the JS console and you'll see what gets sent down. So I wrote a bit of jQuery that checks all of my forms for radio buttons, then sees if there are any presence validations for those buttons. If so, it displays an error message. Note that in Rails, you'll need to wrap your related radio buttons into a div. Hope it helps someone. http://pastebin.com/FMzS9dBj


tagliala commented Feb 8, 2015

@manishie thanks. I'm not confident to add this at the moment but this will definitely help.

manishie commented Feb 8, 2015

oh, I didn't mean for you to add it! It's just a quick hack I threw together to get around the problem. Thanks!


tagliala commented Feb 8, 2015

@manishie sure I got you didn't mean that. I just was informing everyone that I will not do this soon. PR with proper tests are welcomed

had this fixed?


tagliala commented Feb 23, 2017

@august7752 sorry for the very late reply, I've missed this notification.

This feature is not implemented and I will probably not implement this. PR with proper tests are very welcomed

@cooljl31 please use GitHub reactions to add upvotes. Other +1s are here just because there weren't github reactions at the time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment