I have a simple contact form when submitted should set the values inside the contacts section of my model, I have done very little settings/saving on a model so I'm wondering if there is anything in particular to set to a specific part of the model?
JS Data to save (myNewContactObject)
{
"name": "Joe Bloggs",
"email": "[email protected]",
"telephone": "0123456789"
}
Should save to nested contacts array of model, example structure:
[
{
"id": 1,
"name": "model name",
"teams": [
{
"name": "team one name"
},
{
"name": "team two name"
}
],
"contacts": [
{
"name": "James Smith",
"email": "[email protected]",
"telephone": "18917391847"
}
]
}
]
Can I literally just do this.model.set(myNewContactObject)? or do I need to do something like this.model.contacts.set(myNewContactObject)?
Or, maybe this approach is wrong and I should be making a collection out of the contacts like ContactsCollection and setting each ContactModel each time?