40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/components/express_admin/smart_form.rb', line 40
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'
if attrib.name == 'definition'
base_styles = "position: relative; height: 300px;"
target = [attributes[:class].to_a.last, attrib.name].join("_")
textarea attrib.name.to_sym, rows: 10, class: "hide", hidden: true
content_tag(:div, '', id: "ace_#{attrib.name}", class: "ace-input", style: base_styles, data: { target: target })
else
textarea attrib.name.to_sym, rows: 10
end
else
self.send((field_type_substitutions[field_type] || field_type), attrib.name.to_sym)
end
end
end
|