I need to specify a minimum width for a select box input on a form using form_for(@project).
I have <%= f.select(:category, "", html_options{:size => 30} ) %>, but I’m getting a SyntaxError in the ActionController.
Any ideas?
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.
The
selecthelper takes four parameters. If you want to add an attribute to the HTML tag it generates, that’s provided in the fourth parameter. You’ll want to do something like this:The
html_optionsname you see in the Rails API is simply the internal parameter name used by Rails to apply those hash values to the tag it generates. You simply need to provide it a hash.Also, the
sizeof a select box doesn’t set the width or minimum width, it describes the number of elements to make visible vertically (See this jsFiddle for an example). So you may actually be looking for something more like this: