Method: Interview::PolymorphicNestedFormAddLink#build

Defined in:
lib/interview/controls/polymorphic_nested_form_add_link.rb

#build(b) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/interview/controls/polymorphic_nested_form_add_link.rb', line 6

def build(b)
  form_builder = find_attribute! :form_builder
  assoc_method = find_attribute!(:assoc_method).to_sym
  if @polymorphic_classes
    build_polymorphic_link(b, form_builder, assoc_method)
  else
    text = h.t('views.nested_form_add', association: find_attribute!(:singular_title))
    html = render_form(form_builder, assoc_method)
    b.link capion: text, html_options: { href: '#', class: 'nested_form_add_link', data: { content: CGI::escapeHTML(html) } }
  end
end