Merge pull request #2235 from ZeiP/preferences_fixes

Fix the preferences form: Labels' for attributes, boolean fields and …
This commit is contained in:
Matt Rogers 2019-06-13 18:57:03 -05:00 committed by GitHub
commit ece584c3f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 5 deletions

View file

@ -1,11 +1,15 @@
module PreferencesHelper
def pref(model, pref_name, &block)
s = content_tag(:label, Preference.human_attribute_name(pref_name), :for => model+pref_name)
s = content_tag(:label, Preference.human_attribute_name(pref_name), :for => model + "_" + pref_name)
s << yield
s
end
def pref_with_check_box_field(model, pref_name)
pref(model, pref_name) { check_box(model, pref_name, class: "form-control") }
end
def pref_with_select_field(model, pref_name, collection = [ [t('preferences.is_true'),true], [t('preferences.is_false'), false] ])
pref(model, pref_name) { select(model, pref_name, collection, {}, class: "form-control") }
end