[Cakephp] Save multiple associated data

In a one to many relationship, say a question to answers, and I am using javascript to add some answers to the question. It’s best to add the answer fields as follows in the views (replace 0 with a counter variable or something)


<input name="data[Answer][0][answer]">

and make use of the save associated in the controller’s function that handles adding the question as


$this->Question->saveAssociated($this->request->data)

One thought on “[Cakephp] Save multiple associated data

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>