Class: ActiveAdmin::HasManyBuilder

Inherits:
SimpleDelegator
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(has_many_form, assoc, options) ⇒ HasManyBuilder

Returns a new instance of HasManyBuilder.



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/active_admin/form_builder.rb', line 46

def initialize(has_many_form, assoc, options)
  super has_many_form
  @assoc = assoc
  @options = extract_custom_settings!(options.dup)
  @options.reverse_merge!(for: assoc)
  @options[:class] = [options[:class], "inputs has_many_fields"].compact.join(" ")

  if sortable_column
    @options[:for] = [assoc, sorted_children(sortable_column)]
  end
end

Instance Attribute Details

#assocObject (readonly)

Returns the value of attribute assoc.



41
42
43
# File 'lib/active_admin/form_builder.rb', line 41

def assoc
  @assoc
end

#destroy_optionObject (readonly)

Returns the value of attribute destroy_option.



44
45
46
# File 'lib/active_admin/form_builder.rb', line 44

def destroy_option
  @destroy_option
end

#headingObject (readonly)

Returns the value of attribute heading.



43
44
45
# File 'lib/active_admin/form_builder.rb', line 43

def heading
  @heading
end

#new_recordObject (readonly)

Returns the value of attribute new_record.



44
45
46
# File 'lib/active_admin/form_builder.rb', line 44

def new_record
  @new_record
end

#optionsObject (readonly)

Returns the value of attribute options.



42
43
44
# File 'lib/active_admin/form_builder.rb', line 42

def options
  @options
end

#remove_recordObject (readonly)

Returns the value of attribute remove_record.



44
45
46
# File 'lib/active_admin/form_builder.rb', line 44

def remove_record
  @remove_record
end

#sortable_columnObject (readonly)

Returns the value of attribute sortable_column.



43
44
45
# File 'lib/active_admin/form_builder.rb', line 43

def sortable_column
  @sortable_column
end

#sortable_startObject (readonly)

Returns the value of attribute sortable_start.



43
44
45
# File 'lib/active_admin/form_builder.rb', line 43

def sortable_start
  @sortable_start
end

Instance Method Details

#render(&block) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/active_admin/form_builder.rb', line 58

def render(&block)
  html = "".html_safe
  html << template.(:h3) { 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