Class: ExpressAdmin::SmartForm

Inherits:
ExpressTemplates::Components::Base
  • Object
show all
Includes:
ExpressTemplates::Components::Capabilities::Configurable, ExpressTemplates::Components::Capabilities::Resourceful, ExpressTemplates::Components::Forms::FormSupport
Defined in:
app/components/express_admin/smart_form.rb

Constant Summary collapse

TIMESTAMPS =
['updated_at', 'created_at']

Instance Method Summary collapse

Instance Method Details

#form_field_for(attrib) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/components/express_admin/smart_form.rb', line 31

def form_field_for(attrib)
  field_type_substitutions = {'text_area'       => 'textarea',
                              'datetime_select' => 'datetime',
                              'check_box'       => 'checkbox'}
  field_type = attrib.field_type.to_s.sub(/_field$/,'')
  if relation = attrib.name.match(/(\w+)_id$/).try(:[], 1)
    if opts = @config["#{relation}_collection".to_sym]
      select(attrib.name, opts)
    else
      select(attrib.name)
    end
  else
    self.send((field_type_substitutions[field_type] || field_type), attrib.name.to_sym)
  end
end