module SettingsHelper def field(form, key, opts = {}) html = '
' case form.object.column_type(key) when :hidden return form.hidden_field(key) when :boolean, :flag html << form.check_box(key, {}, "true", "false") html << " " # NOTE: Adding space for padding html << h(form.label(key)) when :choice html << h(form.label(key)) html << " " # NOTE: Adding space for padding html << form.select(key, form.object.values_of(key), opts) when :nested child_data = form.object.class.children[key] klass = child_data[:class] options = child_data[:options] children = form.object.send(key) || {"0" => {}} children.each_pair do |index, child| html << %Q!
! if options[:multiple] html << %Q!#{icon('fa-plus')} ! html << %Q! ! end html << h(form.label(key)) form.fields_for("#{key}[#{index}]", klass.new(child)) do |ff| klass::KEYS.each do |k| html << field(ff, k) end end html << "
" end else html << h(form.label(key)) html << form.text_field(key, class: "form-control") end html << "
" html.html_safe end end