我想在以下位置显示标签form_for
:
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
这会生成标签“姓名”,但我希望它是“您的姓名”。我怎样才能改变它?
我想在以下位置显示标签form_for
:
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
这会生成标签“姓名”,但我希望它是“您的姓名”。我怎样才能改变它?
翻译设计表单或其他表单上的标签、占位符和按钮。
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="mt-3">
<label class="float-left"> <%= f.label t(:email) %> </label>
<%= f.email_field :email, class: 'form-control', placeholder: t('.emailholder') %>
</div>
<div class="mt-3">
<label class="float-left"> <%= f.label t(:password) %> </label>
<%= f.password_field :password, class: 'form-control', placeholder: t('.passholder') %>
</div>
<div class="button">
<%= f.button t('.signinbtn'), class: "" %>
</div>
<% end %>
本地文件:config/locales/en.yml
en:
activerecord:
....others
#Found in Views/devise/seasions/new <form> <*label*>
email: "Email"
password: "Password"
#Views/devise <form> <placeholder & buttom>
devise: #if your using devise forms
#seasions/new.html.erb
new:
emailholder: "enter email here"
passholder: "enter password"
signinbtn: "SignIn"
....others