Reputation: 935
I want to use a currency input with simple form rails 4. I have a in my model.
field :minimum_salary, type: Integer
I am using rails 4 simple form, I added a inputs/currency_input.rb as follow:
class CurrencyInput < SimpleForm::Inputs::Base
def input(wrapper_options)
"$ #{@builder.text_field(attribute_name, input_html_options)}".html_safe
end
end
and in my form:
<%= j.input :minimum_salary, as: :currency, placeholder: "minimum", label: false %>
But it is not working. I have the following error: ArgumentError - wrong number of arguments (0 for 1):
Upvotes: 2
Views: 1885
Reputation: 10825
Just remove this wrapper_options
i guess it should works.
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 form this. You can also use mask as it mentioned by link article.
Upvotes: 1