我想使用简单的形式rails 4的货币输入。我的模型中有一个。
field :minimum_salary, type: Integer
我使用rails 4简单的形式,我添加了一个输入/currency_input。
class CurrencyInput < SimpleForm::Inputs::Base
def input(wrapper_options)
"$ #{@builder.text_field(attribute_name, input_html_options)}".html_safe
end
end
和in my form:
<%= j.input :minimum_salary, as: :currency, placeholder: "minimum", label: false %>
但它不起作用。我有以下错误:ArgumentError -参数数目错误(0为1):
只要删除这个wrapper_options
,我想它应该工作。
class CurrencyInput < SimpleForm::Inputs::Base
def input
input_html_options[:type] ||= "text"
"$ #{@builder.text_field(attribute_name, input_html_options)}".html_safe
end
end
Stollen from this。你也可以像链接文章中提到的那样使用遮罩