Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify and style a simple form f.input tag

I have a form in which I'm asking a user chose between a specific collection of options. My form in my codebase looks like this:

= f.label :recognition, "How did you hear about us?", required: false, class: "font required-field"

= f.input :recognition, input_html: { class: "recognitionStyling" }, collection: %w{article blog_post linkedin magazine_ad online_search referral twitter other}, required: false

Now sure this works, but I'm wanting to style this a little bit and having problems doing so.

What I have right now looks like this:

enter image description here

Yet what I am trying to get is something similar to this:

enter image description here

Is there a specific input that I would need to allow for this to happen? What I tried was to add a class on my input called recognitionStyling, which looks like the following, but I don't know if CSS is the way to make this modification.

.recognitionStyling{
  width: 100%;
}
like image 624
kdweber89 Avatar asked Oct 18 '22 11:10

kdweber89


1 Answers

You can consolidate the label into the input and add a placeholder within the input_html:

= f.input :recognition, 
          input_html: { class: "recognitionStyling" }, 
          prompt: "-- SELECT ONE --", 
          collection: %w{article blog_post linkedin magazine_ad online_search referral twitter other}, 
          label: "How did you hear about us?", 
          required: true
like image 143
Anthony E Avatar answered Oct 26 '22 23:10

Anthony E