Class: ActiveAdmin::HasManyBuilder
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ActiveAdmin::HasManyBuilder
- Defined in:
- lib/active_admin/form_builder.rb
Overview
Decorates a FormBuilder with the additional attributes and methods to build a has_many block. Nested has_many blocks are handled by nested decorators.
Instance Attribute Summary collapse
-
#assoc ⇒ Object
readonly
Returns the value of attribute assoc.
-
#destroy_option ⇒ Object
readonly
Returns the value of attribute destroy_option.
-
#heading ⇒ Object
readonly
Returns the value of attribute heading.
-
#new_record ⇒ Object
readonly
Returns the value of attribute new_record.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#remove_record ⇒ Object
readonly
Returns the value of attribute remove_record.
-
#sortable_column ⇒ Object
readonly
Returns the value of attribute sortable_column.
-
#sortable_start ⇒ Object
readonly
Returns the value of attribute sortable_start.
Instance Method Summary collapse
-
#initialize(has_many_form, assoc, options) ⇒ HasManyBuilder
constructor
A new instance of HasManyBuilder.
- #render(&block) ⇒ Object
Constructor Details
#initialize(has_many_form, assoc, options) ⇒ HasManyBuilder
Returns a new instance of HasManyBuilder.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/active_admin/form_builder.rb', line 47 def initialize(has_many_form, assoc, ) super has_many_form @assoc = assoc @options = extract_custom_settings!(.dup) @options.reverse_merge!(for: assoc) @options[:class] = [[:class], "inputs has-many-fields"].compact.join(" ") if sortable_column @options[:for] = [assoc, sorted_children(sortable_column)] end end |
Instance Attribute Details
#assoc ⇒ Object (readonly)
Returns the value of attribute assoc.
42 43 44 |
# File 'lib/active_admin/form_builder.rb', line 42 def assoc @assoc end |
#destroy_option ⇒ Object (readonly)
Returns the value of attribute destroy_option.
45 46 47 |
# File 'lib/active_admin/form_builder.rb', line 45 def destroy_option @destroy_option end |
#heading ⇒ Object (readonly)
Returns the value of attribute heading.
44 45 46 |
# File 'lib/active_admin/form_builder.rb', line 44 def heading @heading end |
#new_record ⇒ Object (readonly)
Returns the value of attribute new_record.
45 46 47 |
# File 'lib/active_admin/form_builder.rb', line 45 def new_record @new_record end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
43 44 45 |
# File 'lib/active_admin/form_builder.rb', line 43 def @options end |
#remove_record ⇒ Object (readonly)
Returns the value of attribute remove_record.
45 46 47 |
# File 'lib/active_admin/form_builder.rb', line 45 def remove_record @remove_record end |
#sortable_column ⇒ Object (readonly)
Returns the value of attribute sortable_column.
44 45 46 |
# File 'lib/active_admin/form_builder.rb', line 44 def sortable_column @sortable_column end |
#sortable_start ⇒ Object (readonly)
Returns the value of attribute sortable_start.
44 45 46 |
# File 'lib/active_admin/form_builder.rb', line 44 def sortable_start @sortable_start end |
Instance Method Details
#render(&block) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/active_admin/form_builder.rb', line 59 def render(&block) html = "".html_safe html << template.content_tag(:h3, class: "has-many-fields-title") { heading } if heading.present? html << template.capture { content_has_many(&block) } html = wrap_div_or_li(html) template.concat(html) if template.output_buffer html end |