开发者

Translating label for references collection_select

开发者 https://www.devze.com 2023-03-05 17:06 出处:网络
i have form with one selectbox (collection_select) for references column. What is proper way to translate label for this widget? For all others a use default Model.human_attribute_name (my code, Trans

i have form with one selectbox (collection_select) for references column. What is proper way to translate label for this widget? For all others a use default Model.human_attribute_name (my code, Translations for Active Record M开发者_运维百科odels)


If you use in your [language].yml file:

attributes:
  my_model:
    property: 'translatet property label'
    [...]

You can simply use the following in your view:

<%= form_for([...]) do |f| %>
  <div class="field">
    <%= f.label :property %><br />
    <%= f.collection_select [...] %>
  </div>
  [...]
0

精彩评论

暂无评论...
验证码 换一张
取 消