Skip to content

Show table helpers: add ability to have a single FORM wrapping several show tables. #771

@prioux

Description

@prioux

Right with each show table helper invocation, we get one form surrounding one table:

<%= show_table(@obj) do |tb, f| %>
   <% tb.edit_cell { f.text_field(:field1) } %>
<% end %>
<%= show_table(@obj) do |tb, f| %>
   <% tb.edit_cell { f.text_field(:field2) } %>
<% end %>

produces this:

<form>
  <table>
     <text_field1/>
  </table>
</form>
<form>
  <table>
     <text_field2/>
  </table>
</form>

If we want to create a single form with multiple tables in it, for the same @obj, we can't.

So let's add a capability to create a table WITHOUT the surrounding form element, and the capability to generate the form context separately. We'll need to pass the form helper around.

Something like

<% show_table_context(@obj) do |cf| %>
  <% show_table(@obj, :form_context => cf) do |tb, f|
      <% tb.edit_cell { f.text_field :field1 } %>
  <% end %>
  <% show_table(@obj, :form_context => cf) do |tb, f|
      <% tb.edit_cell { f.text_field :field2 } %>
  <% end %>
<% end %>

which would produce:

<form>
  <table>
    <text_field1/>
  </table>
  <table>
    <text_field2/>
  </table>
</form>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions