문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top