Sha256: 225f7d7dda31c23147e85f6a59b777a25abba2ddb40e2b7bc27626efea45aebd

Contents?: true

Size: 437 Bytes

Versions: 2

Compression:

Stored size: 437 Bytes

Contents

class CurrencyInput < SimpleForm::Inputs::Base
  include ActionView::Helpers::NumberHelper

  def input
    input_field = @builder.text_field(attribute_name, input_html_options)
  end

  def input_html_options
    merge_formatted_value(super)
  end

  private

  def merge_formatted_value(hash)
    if object.errors[attribute_name].empty?
      hash[:value] ||= number_to_currency(object.send(attribute_name))
    end
    hash
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
undercase-0.2.57 app/inputs/currency_input.rb
undercase-0.2.29 app/inputs/currency_input.rb