Schemas and Objects combined


#1

I’ll try and make this short. I’m looking to make a form that will have four inputs, then with the push of a button, I can add another four identical inputs directly below the first, and do this for nth number of times. When I submit at the end, whether I have the original four input fields, or 7 more duplicates of the four fields, how can I save however many as one item in mongo?

For example:

First | Last | Age | Grade
submit

or

First | Last | Age | Grade
First | Last | Age | Grade
First | Last | Age | Grade
First | Last | Age | Grade
submit


#2

Iterate over all the rows (First | Last | Age | Grade). Each row is a fieldset.

Pseudo code:

this.$('fieldset').each(function () {
  var fieldset = $(this);
  var data = {
    first: $('input[name="first"]', fieldset).value(),
    // TODO: The same for last, age and grade
  });
  // TODO: Validate
  MyCollection.insert(data);
});