Sha256: e8dfe446c9246a238f97470ea8708c7fb930a725772d3a1dc8c6a62759074543

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

module SimpleAdmin
  module FormHelper
    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
          content_tag :fieldset, options do
            content_tag :legend do
              options[:legend]
            end unless options[:legend].blank
            form_fields(form, col[:attributes])
          end
        else
          content_tag :div, options do
            form_fields(form, col[:attributes])
          end
        end
      end.join.html_safe
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_admin-0.7.1 app/helpers/simple_admin/form_helper.rb