I think that easy solution is to overwrite the save method of the object wich is on the embeded form.
Just test if there are some values and if not, end the method. If yes, call parent::save() On 30 čnc, 01:51, J_Wesker <j_chave...@hotmail.com> wrote: > After making some changes on my code and debugging using die's and > var_dump() all day, > I haven't found the cause of all this. But I have make sure of some > facts: > > 1. If I embed directly the comment form, and set the body field as > required, then both objects get saved smoothly, > unfortunately the bussiness rules I'm following here don't apply. > > 2. On my extended saveEmbeddedForms() method, $comment is actually > NULL, > because on the custom post validator, if no body comment is entered, > the comment value > is unset. Therefore, the condition we discussed before complies > correctly when necessary. > > 3. Even though the values from the embedded form aren't set, the > comment form is saved anyway if left blank. > > I came to the point to think that perhaps the relation between the > comment and user table might be the cause, > and then I decided to remove the relation from the comment table, but > still, the embed form is saved blank. > If not removing the relationship and with the following updated code, > I get a Propel Exception only when the comment > is left blank. > > http://pastie.org/1066339 / model > > http://pastie.org/1066347 / ExpenseForm > > http://pastie.org/1066350 / ExpenseCommentValidatorSchema > > http://pastie.org/1066353 / ExpenseCommentForm > > http://pastie.org/1066364 / PropelException generated > > UPDATE!!! > > While writing this post I made a breaktrhough with this, but even so, > I'm still missing something... > > If instead of defining the relationship between Expense and Comment > objects in the ExpenseForm like this: > > $comment->setExpense($this->getObject()); > > to this: > > $comment->setExpenseId($this->getObject()->getId()); > > when editing an existing expense, comments are saved correctly, and > most important no blank comment is saved! > > There is a big BUT, however, the expense object doesn't get an ID > until after saving the embeded objects, so, how > can I approach this for new expense forms??? > > Apparently the problem is about how Propel saves embedded objects, > because as a direct object relation was made > with $comment->setExpense(), the saving of the embed object is forced, > even if the embed form is deleted >S > > Any ideas on how to solve this? > > I will try to analyze more the flow used in sfFormObject::save() > method tomorrow, and perhaps extending some of the method > calls used by save() I will find the answer. If someone has any > suggestion or idea please let me know :) > > Best regards! -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en