Using simple_form, I have a simple input like this:
<%= f.input :email %>
This generates (removed irrelevant parts):
...
<label>Email</label>
<input .... />
...
I want the input control to come below the label, so I need a <br/>
after </label>
:
...
<label>Email</label>
<br/>
<input .... />
...
inserting a <br/>
in config/initializers/simple_form.rb
:
config.label_text = lambda { |label, required| "#{required} #{label} <br/>" }
And this generates:
...
<label>Email<br/></label> #note the location of <br/>
<input .... />
...
The <br/>
is just before the </label>
. Now, this works in terms of showing the input on the next "line", but it just feels "wrong".
Is there some way to do this properly?
Totally agree you should use css to do this as Steve described. But if you really want to, you can still do this by using rails' default form helper like so:
<%= f.label :email %> <br> <%= f.text_field :email %>
It's usually better to do this with stylesheet rules than by inserting HTML tags, since the break is a matter of formatting rather than of content. It could be something as simple as...
label {
display: block;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With