Module: ActiveScaffold::Bridges::DatePicker::Helper::FormColumnHelpers

Defined in:
lib/active_scaffold/bridges/date_picker/helper.rb

Instance Method Summary collapse

Instance Method Details

#active_scaffold_input_date_picker(column, options, ui_options: column.options) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/active_scaffold/bridges/date_picker/helper.rb', line 174

def active_scaffold_input_date_picker(column, options, ui_options: column.options)
  record = options[:object]
  options = active_scaffold_input_text_options(options.merge(ui_options))
  options[:class] << " #{column.form_ui}"

  format = datepicker_format(ui_options, column.form_ui)
  conversion = column.form_ui == :date_picker ? :to_date : :to_time
  value = controller.class.condition_value_for_datetime(column, record.send(column.name), conversion, ui_method: :form_ui, ui_options: ui_options)
  options[:data] = datepicker_format_options(column, format).reverse_merge!(options[:data] || {})
  options[:value] = (value ? l(value, format: format) : nil)
  text_field(:record, column.name, options)
end