2
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
|
# File 'app/helpers/rails_info/form_helper.rb', line 2
def rails_info_field(name, options = {})
error = @filter.errors[name]
hint = options.delete(:hint)
content_tag :div, class: 'control-group' + (error ? ' error' : '') do
content = []
content << label_tag("filter[#{name}]", name.humanize, class: 'control-label')
content << content_tag(:div, class: 'controls') do
controls = []
unless block_given?
controls << text_field_tag("filter[#{name}]", @filter.send(name), options)
end
controls << content_tag(:p, hint, class: 'help-block') if hint
controls << content_tag(:span, error, class: 'help-inline') if error
controls = controls.join(' ')
if block_given?
yield(name, controls)
else
raw controls
end
end
raw content.join(' ')
end
end
|