Skip to content

Settting custom view for nested (has_many) form field

Lukas Svoboda edited this page Oct 22, 2013 · 1 revision

you can use configure_nested_form method for this.

- edit_form.configure do |form|
  - form.field(:test_steps).configure_nested_form do |nform|
    - f1 = nform.field :action do |f| 
      - f.html_attributes = { class: 'span3' }

    - f2 = nform.field :action_data do |f| 
      - f.html_attributes = { class: 'span3' }

    - f3 = nform.field :action_result do |f| 
      - f.html_attributes = { class: 'span3' }

    - f = nform.default_group.content_for_field :action_data do |f1|
      -# empty
    - f = nform.default_group.content_for_field :action_result do |f1|
      -# empty

    - f3 = nform.default_group.content_for_field :action do |f1|
      = nform.input :action_result do
        = nform.render_textfield f1, placeholder: 'Action'
        = nform.render_textfield f2, placeholder: 'ActionData'
        = nform.render_textfield f3, placeholder: 'ActionResult'

= form_render edit_form