简体   繁体   中英

How do I display error messages for validation on a collection select work simple_form?

I'm on mobile so don't have access to my code until later. But the basics are this: I have a simple_form to create/edit a listing on my site. Certain parameters are required. I use validates presence of in the model. When submitting the form, if I text box that is required isn't filled out, the validation works fine, error pops up and says please fill in. When a button is not selected for one of the collection selects, nothing happens. Obviously the validation is working because the form won't submit, but no error is thrown. Any ideas on how to get the error to show for a collection select with radio buttons?

In your form do you have?

<%= form.error_notification %>

Or you can do it in a different way, if you don't want to do it with the form helper.

<%= @instance_variable.errors.full_messages if @instance_variable.errors.any? %>

You can read more here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM