Sha256: cc9363ea03e9dabdc395e802bca4a37bc2dee3823fc9d6dd19b84be1c2a9bf3b

Contents?: true

Size: 1.16 KB

Versions: 51

Compression:

Stored size: 1.16 KB

Contents

module ActiveAdmin
  module Views
    module Pages

      class Form < Base

        def title
          I18n.t("active_admin.#{params[:action]}_model",
                 :model => active_admin_config.resource_label)
        end

        def form_presenter
            active_admin_config.get_page_presenter(:form) || default_form_config
        end

        def main_content
          form_options = default_form_options.merge(form_presenter.options)

          if form_options[:partial]
            render(form_options[:partial])
          else
            active_admin_form_for(resource, form_options) do |f|
              instance_exec f, &form_presenter.block
            end
          end
        end

        private

        def default_form_options
          {
            :url => default_form_path,
            :as => active_admin_config.resource_name.singular
          }
        end

        def default_form_path
          resource.persisted? ? resource_path(resource) : collection_path
        end

        def default_form_config
          ActiveAdmin::PagePresenter.new do |f|
            f.inputs
            f.actions
          end
        end
      end

    end
  end
end

Version data entries

51 entries across 51 versions & 3 rubygems

Version Path
aa-rails4-0.6.0 lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.141 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/lib/active_admin/views/pages/form.rb