File: _form_polymorphic_association.html.haml

package info (click to toggle)
ruby-rails-admin 0.8.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,492 kB
  • ctags: 1,292
  • sloc: ruby: 5,341; makefile: 3
file content (11 lines) | stat: -rw-r--r-- 726 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
:ruby
  type_collection = field.polymorphic_type_collection
  type_column = field.association.foreign_type.to_s
  selected_type = field.bindings[:object].send(type_column)
  collection = field.associated_collection(selected_type)
  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-inline
  = form.select type_column, type_collection, {include_blank: true, selected: selected_type}, class: "form-control", 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)}, class: "form-control"