How to use placeholders instead of labels in simple_form?
You need 3 steps to enable showing placeholders instead of labels automatically and need to do more configurations.
make sure
b.use :placeholder
in simple_form.rbmake sure
b.use :input
instead ofb.use :label_input
most important, modify your simple_form.en.yml:
en:
simple_form:
"yes": 'Yes'
"no": 'No'
required:
text: 'required'
mark: '*'
placeholders:
user:
name: 'name'
in your page:
<%= simple_form_for @user do |f|%>
<%= f.input :name%>
<% end%>
Every placeholder needs to be defined here, or it will not display.
simple_form
lets you hide an individual label by passing in
label:false
to each input. For example:
<%= f.input :email, placeholder: 'Email', label:false %>
will hide the label for your email input in a form.