Using simple_form -- is there a way to change where the input field's label is placed? If for example, I wanted to place the label above the 开发者_如何学运维field, how would I do that?
In the CSS styles for the label and/or input, add display: block;
.
The accepted answer will render the label below the checkbox, not above it. If you want to position the label above (or to the left), you can explicitly add it with f.label
:
label above:
simple_form_for my_model do |f|
f.label :my_boolean_field
f.input :my_boolean_field, style: 'display: block;'
label to the left:
simple_form_for my_model do |f|
f.label :my_boolean_field
f.input :my_boolean_field
When you don't include an explicit label
, it will appear to the right of the checkbox or below it:
label below:
simple_form_for my_model do |f|
f.input :my_boolean_field, style: 'display: block;'
label to the right (why is this the default
精彩评论