Question

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):

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top