Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting all repeat items in repeating table rows #76

Closed
JREubanks opened this issue Nov 7, 2017 · 0 comments
Closed

Not getting all repeat items in repeating table rows #76

JREubanks opened this issue Nov 7, 2017 · 0 comments

Comments

@JREubanks
Copy link

I have the following HTML in my form:

<form class='container repeater' novalidate method='post'> 
  <div id='w2bw2c-contacts-div' data-repeater-list="contact">
     <table data-repeater-list class="table table-responsive" id="contacts-table">
           <tr class="table-inverse" >
               <th>#</th>
               <th style="width: 20%;">Name</th>
               <th style="width: 20%;">Title</th>
               <th style="width: 20%;">EMail</th>
               <th style="width: 15%;">Phone</th>
               <th style="width: 15%;">Fax</th>
                <th>Delete</th>
             </tr>
       </table>
       <input data-repeater-create type="button" id="add-contact-button" value="Add Contact"/>
  </div>
</form>

I'm using the following jQuery functions to add and delete repeater items:

$('#add-contact-button').click(function() {
   console.log('Add Contact button clicked.');
   var rowCount = jQuery('#contacts-table tr').length;
   $('#contacts-table').append('<tr class="mb-0"><td>' + rowCount + '</td>' +
        '<td data-repeater-item><div class="form-group">' +
        '<input type="text" class="form-control" name="contact_name"></div></td>' + 
        '<td data-repeater-item><div class="form-group">' +
        '<input type="text" class="form-control" name="contact_title"></div></td>' +
        '<td data-repeater-item><div class="form-group">' +
        '<input type="text" class="form-control" name="contact_phone"></div></td>' +
        '<td data-repeater-item><div class="form-group">' +
        '<input type="text" class="form-control" name="contact_fax"></div></td>' +
        '<td data-repeater-item><div class="form-group">' +
        '<input type="text" class="form-control" name="contact_email"></div></td>' +
        '<td><input data-repeater-delete type="button" value="&times;"/>' +
         '</td></tr>');
});

$('body').on('click', '.delete-contact', function () {
      jQuery(this).closest('tr').remove();
      var contactTable = document.getElementById("contacts-table");
          for (var i = 1; i < contactTable.rows.length; i++) {
              contactTable.rows[i].cells[0].innerHTML = i;
          }
});

The user interface seems to work fine, but my $_POST data just shows the last repeater item with the names shown in the template. How can I get the entire set of repeating items into my POST data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant