jeudi 16 avril 2015

Rails Select helper in form required True not working

I have a Rails 3.2.21 app in which I'm using a select helper in a form like so:



<%= f.select :phys_option, options_for_select([["N/A", "n/a"], ["No", "no"], ["Yes", "yes"]], :selected => @call.phys_option), :include_blank => true, :required => true, :class => 'select' %>


This works with basic functionality for selecting an option, including a blank option, etc. But what doesn't work is the :required => true or the :class => 'select'. I can submit the form even when the selection is blank and my class for the select2 gem select doesn't work on this helper method.


Is my syntax wrong or am I missing something? I can call a model validation to ensure the fields are filled out, but I'd much rather avoid more model validations and try to use the :required => true to force a selection.


Any thoughts on why this isn't working?


If you need further detail and/or code, please let me know.


Aucun commentaire:

Enregistrer un commentaire