Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editable table with AutoForm in Meteor

How can I make a table with input fields in Meteor. I've used the example from http://autoform.meteor.com/update-each but they only use 1 input field.

The functionality works with this code:

  <tbody>
    {{#each persons}}
      {{#autoForm id=makeUniqueID type="update" collection=Collections.Persons doc=this autosave=true}}
      <tr>
        <td>{{> afFieldInput name="fullName" label=false}}</td>
        <td>{{> afFieldInput name="email" label=false}}</td>
        <td>{{> afFieldInput name="address" label=false}}</td>
        <td><button type="submit" class="btn btn-xs btn-danger">Delete</button></td>
      </tr>
      {{/autoForm}}
    {{/each}}
  </tbody>

but it created a <form> element around each <tr> and it screws up my html. What is the correct way to do it?

like image 592
Jamgreen Avatar asked Dec 15 '14 10:12

Jamgreen


Video Answer


1 Answers

Use divs with CSS:

<div class="table">
  {{#each persons}}
    {{autoform class="tr"}}
      <div class="td">{{> afQuickField}}</div>
      <div class="td">{{> afQuickField}}</div>
      <div class="td">{{> afQuickField}}</div>
    {{/autoform}}
  {{/each}}
</div>

And style it as such:

.table {
  display: table;
}

.tr {
  display: table-row;
}

.td {
  display: table-cell
}
like image 79
rclai Avatar answered Sep 18 '22 18:09

rclai