How to insert tags after tag in simple_form?

Using simple_form , I have simple input:

<%= f.input :email %>

This generates (removes irrelevant parts):

...
  <label>Email</label>
  <input .... />
...

I want the input control to be under the label, so I need <br/>after </label>:

...
  <label>Email</label>
  <br/>
  <input .... />
...

How to do it?

I tried:

insert <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 .... />
...

<br/>is in front of the symbol </label>. Now this works in terms of displaying input on the next "line", but it is simply "wrong."

Is there any way to do this right?

+3
source share
2 answers

, HTML, - , . - ...

label {
    display: block;
}
+10

, css , . , , rails:

<%= f.label :email %>
<br>
<%= f.text_field :email %>
0

Source: https://habr.com/ru/post/1792164/


All Articles