45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'app/components/express_admin/smart_form.rb', line 45
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$/,'')
field_type = "password" if attrib.name.match(/password/)
if relation = attrib.name.match(/(\w+)_id$/).try(:[], 1)
select(attrib.name.to_sym, options: config["#{relation}_collection".to_sym], select2: true)
else
if field_type == 'text_area'
textarea attrib.name.to_sym, rows: 10
else
self.send((field_type_substitutions[field_type] || field_type), attrib.name.to_sym)
end
end
end
|