43
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

form.labelの使用方法

Posted at

#参考リンク
Railsドキュメント

###form.labelの項目を変更する。

app/views/courts/_form.html.erb
  <div class="field">    
    <%= form.label :store_name %>
    <%= form.text_field :store_name %>
  </div>

  <div class="field">
    <%= form.label :address %>
    <%= form.text_field :address %>
  </div>

項目名としてstore_nameを「店舗名」に、addressを「住所」に変更したい。

app/views/courts/_form.html.erb
  <div class="field">    
    <%= form.label :store_name, "店舗名(必須)" %>
    <%= form.text_field :store_name %>
  </div>

  <div class="field">
    <%= form.label :address, "住所" %>
    <%= form.text_field :address %>
  </div>

と、変更すると理想通りviewで表示される。

43
36
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
43
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?