I can’t seem to find the syntax to add a class to a select tag generated by Rails collection_select. Some help?
I can’t seem to find the syntax to add a class to a select
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Many Rails helpers take multiple hash arguments. The first is usually the options to control the helper itself, and the second is the html_options where you specifiy custom ids, classes etc.
The method definition looks like this:
You’ll notice the multiple ‘= {}’ in the params list. To use this, the first set of options that you would specify must actually be enclosed in braces:
If you don’t have any options to specify besides the html class, then just put an empty hash placeholder:
Additional API documentation is available at:
http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/collection_select