我不想使用默認使用翻譯提交按鈕
<%= f.submit %>
,並創造了它的輔助功能,其中還嵌入了一個圖標。輔助函數需要一個標籤放在新創建的按鈕上。
我打電話這樣說:
<%= submit_button("icon-plus", I18n.translate("helpers.submit.create")) %>
但現在這個文本按鈕上顯示:
%{}模型toevoegen
相反的:
產品類型toevoegen
如果我使用正常的提交按鈕,則出現正確的文本,所以我的yml文件是正確的。我怎樣才能得到正確的文字在助手中使用?
助手代碼:
def submit_button(icon, label)
link_to "javascript:void(0)", :class => 'btn btn-primary', :onclick => "$(this).closest('form').submit()" do
raw('<div class="') + icon + raw(' icon-white"> ') + label +raw('</div>')
end
end
你能提供幫助代碼嗎?我懷疑你需要用'#{model}'替換'%{model}'。 –
添加了助手代碼。我已經嘗試將代碼替換爲#{model},但這不起作用,甚至打破了正常提交的標題。 – rept