22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/presenters/commit_filter/presenters/frameworks/twitter_bootstrap/version3_presenter.rb', line 22
def form_field(filter, name, options = {})
options[:placeholder] = t("commit_filter.filters.form.fields.#{name}.placeholder", default: 'NULL')
options.delete :placeholder if options[:placeholder] == 'NULL'
hint = t("commit_filter.filters.form.fields.#{name}.hint", default: 'NULL')
hint = nil if hint == 'NULL'
error = (filter.errors || {})[name]
field = options.delete(:field)
content_tag :div, class: 'form-group' + (error ? ' has-error' : '') do
content = []
content << label_tag("filter[#{name}]", t("commit_filter.filters.form.fields.#{name}.title"), class: 'col-sm-3 control-label')
content << content_tag(:div, class: 'col-sm-8') do
controls = []
if field.present?
controls << field
else
controls << text_field_tag("filter[#{name}]", filter.send(name), { class: 'form-control' }.merge(options))
end
controls << content_tag(:p, hint, class: 'help-block') if hint
controls << content_tag(:span, error, class: 'help-inline') if error
raw controls.join(' ')
end
raw content.join(' ')
end
end
|