public function duplicate($id) { // reembed duplicated comment $Comments = Doctrine::getTable('Comments')->findForTable('loans', $id); foreach ($Comments as $key => $val) { $comment = new Comments(); $comment->fromArray($val->toArray()); $form = new CommentsSubForm($comment); $this->attachEmbedRecord('Comments', $form, $key); } // reembed duplicated insurances $Insurances = Doctrine::getTable('Insurances')->findForTable('loans', $id); foreach ($Insurances as $key => $val) { $insurance = new Insurances(); $insurance->fromArray($val->toArray()); $form = new InsurancesSubForm($insurance); $this->attachEmbedRecord('Insurances', $form, $key); } }