Module: SimpleAdmin::FormHelper

Included in:
AdminHelper
Defined in:
app/helpers/simple_admin/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#form_field(form, col) ⇒ Object



28
29
30
31
32
# File 'app/helpers/simple_admin/form_helper.rb', line 28

def form_field(form, col)
  options = (col[:options] || {}).dup
  expand_block_options!(options)
  form.input col[:attribute], options
end

#form_fields(form, attributes) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/simple_admin/form_helper.rb', line 3

def form_fields(form, attributes)
  attributes.map do |col|
    options = (col[:options] || {}).dup
    expand_block_options!(options)

    case col[:kind]
    when :attribute
      form.input col[:attribute], options
    when :content
      instance_exec(@resource, form, col, &col[:data])
    when :fieldset
       :fieldset, options do
         :legend do
          options[:legend]
        end unless options[:legend].blank
        form_fields(form, col[:attributes])
      end
    else
       :div, options do
        form_fields(form, col[:attributes])
      end
    end
  end.join.html_safe
end