Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improve nested_attributes for polymorphic parent

  • Loading branch information...
commit 7537736040bfbe868d0c942e3b14f6f69506b41e 1 parent 73e8b9a
@netoctone authored
View
9 app/views/rails_admin/main/_form_polymorphic_association.html.haml
@@ -6,5 +6,10 @@
selected = field.bindings[:object].send(field.association[:name])
column_type_dom_id = form.dom_id(field).sub(field.method_name.to_s, type_column)
-= form.select type_column, type_collection, {:include_blank => true, :selected => selected_type}, :id => column_type_dom_id, :data => { :polymorphic => true, :urls => field.polymorphic_type_urls.to_json }
-= form.select field.method_name, collection, {:include_blank => true, :selected => selected.try(:id)}, :style => "margin-left:10px;"
+- if field.section.kind_of?(RailsAdmin::Config::Section::Nested)
+ - selected = field.bindings[:form].options[:parent_builder].object
+ = form.hidden_field type_column, value: selected.id
+ = form.hidden_field field.method_name, value: selected.class.name
+- else
+ = form.select type_column, type_collection, {:include_blank => true, :selected => selected_type}, :id => column_type_dom_id, :data => { :polymorphic => true, :urls => field.polymorphic_type_urls.to_json }
+ = form.select field.method_name, collection, {:include_blank => true, :selected => selected.try(:id)}, :style => "margin-left:10px;"
Please sign in to comment.
Something went wrong with that request. Please try again.