Class: Interview::NestedFormAddLink
- Defined in:
- lib/interview/nested_form_add_link.rb
Instance Attribute Summary collapse
-
#polymorphic_classes ⇒ Object
Returns the value of attribute polymorphic_classes.
-
#style ⇒ Object
Returns the value of attribute style.
Attributes inherited from Control
Instance Method Summary collapse
Methods inherited from Control
#ancestors, build, definition, #find_attribute, #find_attribute!, inherited, #initialize, #set_attributes, #set_defaults
Constructor Details
This class inherits a constructor from Interview::Control
Instance Attribute Details
#polymorphic_classes ⇒ Object
Returns the value of attribute polymorphic_classes.
4 5 6 |
# File 'lib/interview/nested_form_add_link.rb', line 4 def polymorphic_classes @polymorphic_classes end |
#style ⇒ Object
Returns the value of attribute style.
4 5 6 |
# File 'lib/interview/nested_form_add_link.rb', line 4 def style @style end |
Instance Method Details
#render ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/interview/nested_form_add_link.rb', line 6 def render if @style and @style.to_sym == :horizontal_form html = Builder::XmlMarkup.new # todo: in eigenes Objekt auslagern? html.div class: 'row' do html.div class: 'col-xs-9 col-xs-offset-3' do html << render_link end end return html.target! else return render_link end end |
#render_link ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/interview/nested_form_add_link.rb', line 20 def render_link form_builder = find_attribute! :form_builder assoc_method = find_attribute!(:assoc_method).to_sym if @polymorphic_classes return render_polymorphic_link(form_builder, assoc_method) else html = render_form(form_builder, assoc_method) text = h.t('views.nested_form_add', association: find_attribute!(:singular_title)) return h.content_tag :a, text, { href: '#', class: 'nested_form_add_link', data: { content: CGI::escapeHTML(html) } }, false end end |