3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/helpers/express_admin/module_settings_helper.rb', line 3
def edit_setting(param)
setting = setting_for(param)
domkey = param.gsub(/\W/, '_')
name = "settings[#{param}]"
title = param.titlecase
value = params[param.to_sym].nil? ? setting.value : params[param.to_sym]
html = ""
if setting.boolean?
html << content_tag(:div, class: 'form-group') do
hidden_field_tag(name, '0') +
check_box_tag(name, true, value, class: 'setting', id: domkey) +
content_tag(:label, title, class: 'checkbox', for: domkey)
end
elsif setting.selector?
html << content_tag(:div, class: 'form-group') do
content_tag(:label, title, for: domkey) +
select_tag(name, options_for_select(setting.definition.selection, value), class: 'setting', id: domkey)
end
else
html << content_tag(:div, class: 'form-group') do
content_tag(:label, title, for: domkey) +
text_field_tag(name, value, class: 'textbox', id: domkey)
end
end
if setting.errors.messages[:value]
html << content_tag(:span, [setting.errors.messages[:value]].flatten.first, class: 'error')
html = content_tag(:span, html, class: "error-with-field")
end
html.html_safe
end
|