Module: ActiveScaffold::Bridges::DatePicker::DatePickerBridge

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

Instance Method Summary collapse

Instance Method Details

#initialize(model_id) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/active_scaffold/bridges/date_picker/ext.rb', line 11

def initialize(model_id)
  super
  return unless ActiveScaffold::Bridges::DatePicker.default_ui

  date_picker_fields = _columns.collect { |c| {:name => c.name.to_sym, :type => c.type} if %i[date datetime].include?(c.type) }.compact
  # check to see if file column was used on the model
  return if date_picker_fields.empty?

  # automatically set the forum_ui to a date_picker or datetime_picker
  date_picker_fields.each do |field|
    col_config = columns[field[:name]]
    col_config.form_ui = (field[:type] == :date ? :date_picker : :datetime_picker)
  end
end