Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow Modal Config Section

  • Loading branch information...
commit 4dfea0e8947516a14868824a3ef02e160b30aff3 1 parent db1ac45
@ehoch ehoch authored
View
11 app/helpers/rails_admin/form_builder.rb
@@ -10,7 +10,16 @@ def generate(options = {})
:model_config => @template.instance_variable_get(:@model_config),
:nested_in => false
})
- groups = options[:model_config].send(options[:nested_in] ? :nested : options[:action]).with(:form => self, :object => @object, :view => @template).visible_groups
+
+ if options[:nested_in]
+ action = :nested
+ elsif @template.request.format == 'text/javascript'
+ action = :modal
+ else
+ action = options[:action]
+ end
+
+ groups = options[:model_config].send(action).with(:form => self, :object => @object, :view => @template).visible_groups
object_infos +
groups.map do |fieldset|
View
1  lib/rails_admin/config/sections.rb
@@ -4,6 +4,7 @@
require 'rails_admin/config/sections/update'
require 'rails_admin/config/sections/create'
require 'rails_admin/config/sections/nested'
+require 'rails_admin/config/sections/modal'
require 'rails_admin/config/sections/list'
require 'rails_admin/config/sections/export'
require 'rails_admin/config/sections/show'
View
10 lib/rails_admin/config/sections/modal.rb
@@ -0,0 +1,10 @@
+require 'rails_admin/config/sections/edit'
+
+module RailsAdmin
+ module Config
+ module Sections
+ class Modal < RailsAdmin::Config::Sections::Edit
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.