翻译form_tag提交按钮

时间:2017-02-25 07:34:16

标签: ruby-on-rails

在Rails中,当你有这样的表格时:

<% form_for @post do |f| %>
  <%= f.submit %>
<% end %>

单击按钮时,您可以使用这样的特定翻译:

en:
  helpers:
    submit:
      create: "Create a {{model}}"
      update: "Confirm changes to {{model}}"

但我有一个form_tag,它将GET提交到索引路径以设置过滤器:

= form_tag admin_dashboard_index_path, method: :get, class: "table_filter" do
  = select_tag :company, options_for_select(@filter_companies.map{ |c| [c.name, c.id] }, params[:company]), include_blank: true, class: "selected"
  = submit_tag :submit, value: I18n.t('.general.filter'), class: 'btn'

如何针对这种情况获得具体的翻译?

1 个答案:

答案 0 :(得分:0)

将此添加到方法中,以便按下后按钮标签保持不变。

= submit_tag :submit, value: t('.general.filter'), class: 'btn', data: { disable_with: t('.general.filter') }

submit_tag method