Sha256: 162f240f863a6c4622532a1f9bb38ff1083be8f3ad93c69010225d6392b2fd15

Contents?: true

Size: 643 Bytes

Versions: 16

Compression:

Stored size: 643 Bytes

Contents

class DateFieldInput < SimpleForm::Inputs::StringInput
  # Normalizes to localized date
  def date_value
    value = object.send(attribute_name)

    return nil unless value.present?

    value = Date.parse(value) if value.is_a? String

    I18n.localize(value)
  end

  def input
    input_html_options[:type] = 'text'
    template.content_tag(:div, :class => 'input-append date-picker date') do
      @builder.text_field(attribute_name, input_html_options.merge(:value => date_value)) +
        template.content_tag(:div, :class => 'add-on') do
          template.content_tag(:i, '', :class => 'icon-calendar')
        end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
has_accounts_engine-3.0.0.beta15 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta14 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta13 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta12 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta11 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta10 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta9 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta8 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta7 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta6 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta5 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta4 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta3 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta2 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta1 app/inputs/date_field_input.rb
has_accounts_engine-3.0.0.beta0 app/inputs/date_field_input.rb