module Admin::ConfigurationHelper
def edit_config(key, options={})
=>
def edit_config(key, options={}) setting = setting_for(key) domkey = key.gsub(/\W/, '_') name = "trusty_config[#{key}]" title = t("trusty_config.#{key}").titlecase title << content_tag(:span, " (#{t("units.#{setting.units}")})", :class => 'units') if setting.units value = params[key.to_sym].nil? ? setting.value : params[key.to_sym] html = "" if setting.boolean? html << hidden_field_tag(name, 0) html << check_box_tag(name, 1, value, :class => 'setting', :id => domkey) html << content_tag(:label, title.html_safe, :class => 'checkbox', :for => domkey) elsif setting.selector? html << content_tag(:label, title.html_safe, :for => domkey) html << select_tag(name, options_for_select(setting.definition.selection, value), :class => 'setting', :id => domkey) else html << content_tag(:label, title.html_safe, :for => domkey) html << text_field_tag(name, value, :class => 'textbox', :id => domkey) end if setting.errors[:value].present? html << content_tag(:span, [setting.errors[:value]].flatten.first, :class => 'error') html = content_tag(:span, html.html_safe, :class => "error-with-field") end html.html_safe end