Hello,
SaveAll works great with the examples provided in the docs and through
the majority of blogs.
My Problem is that I want to Save three nested Models at once.
Currently I do this with the help of transactions and some awkward
validation.
For example I have these Models:
Test has many Question and Question has many Answer.
If I just want to save the Questions and their related Answers or the
Tests and their related Questions it works like a charm. But when I
want to save all three plus validation it just works on the first two
of them.
View
echo $form->input('Test.name');
[...]
for( $i = 0; $i<2; $i++ )
{
echo $form->input("Question.{$i}.name");
[...]
for( $j = 0; $j < 3; $j++ )
echo $form->input("Answer.{$i}.{$j}.name");
}
Furthermore Cake seems to loose the Form values of the Answer Fields
submitted via POST. It just keeps the last one:
In my Example I have two questions with three answer fields. This
means that the Keys Answer[0] and Answer[1] are already occupied. Cake
now only remembers the the third answer field of every question (e.g.
Answer[0][3] and Answer[1][3]). If I generate three questions Cake
would only remember the fourth answer field.
This problem can be solved If I start $j at the size of the questions
I want to show,
e.g. 3
Answer[0][3], Answer[0][4], Answer[0][5]
Answer[1][3], Answer[1][4], Answer[1][5]
Answer[2][3], Answer[2][4], Answer[2][5]
I hope someone can help me.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---