Why would it be always false? In the validator I'm unsetting the comment reference if body field has no value...
<?php class ExpenseCommentValidatorSchema extends sfValidatorSchema { /** * Validate comment field * * @param array $values * @return array $values */ protected function doClean($values) { // no comment, remove the empty values if (!$values['comment']['body']) { unset($values['comment']); } return $values; } } Or perhaps I'm having a logic failure :( On Jul 28, 9:42 pm, Gustavo Adrian <comfortablynum...@gmail.com> wrote: > Sorry, the last line I was talking about is: > > *if** (**!**isset**(**$comment**)) > { > **unset**(**$forms**[**'**comment**'**]); > > } > > The if condition would be always false* > > On Wed, Jul 28, 2010 at 11:40 PM, Gustavo Adrian < > > comfortablynum...@gmail.com> wrote: > > Maybe I'm wrong but.. isn't $comment set already on this line by > > 'getValue'? (saveEmbeddedForms of ExpenseForm) > > > *$comment** **=** **$this**->**getValue**(**'**comment**'**);*So the line: > > > *unset**(**$forms**[**'**comment**'**]);* > > > doesn't execute never? > > > On Wed, Jul 28, 2010 at 11:22 PM, J_Wesker <j_chave...@hotmail.com> wrote: > > >> Hi symfony guys! > > >> I've been working on embedded forms for some days now, and I'm really > >> getting desperate > > >> This is my story: > > >> I have 3 tables... expense, user and comment; they have a 1:N > >> relationship, where the user must be able to type a new comment each > >> time the form is displayed. So, I need to embed a new CommentForm into > >> ExpenseForm, and this CommentForm should be optional except in some > >> cases. > > >> My development environment is: > >> OS: Fedora 13 > >> Web Server: Apache 2 > >> PHP 5.3 > >> MySQL 5.1 > >> symfony 1.4 > >> ORM: Propel 1.4 > > >> I have the code right now, based on the Advanced Forms Chapter of the > >> Do More With symfony book at > >>http://www.symfony-project.org/more-with-symfony/1_4/en/06-A > >> dvanced-Forms<http://www.symfony-project.org/more-with-symfony/1_4/en/06-Advanced-F...>but > >> I haven't found out yet what is the cause for this > >> not to be working by now. Although there are some differences, like > >> using Doctrine instead of Propel, and having a several embedded > >> objects in the form, i managed to map my case to the example: > > >> In order to not clutter this post with code and scare people away, I > >> have sectioned and paste it usinghttp://pastie.com, so it looks > >> better and be easier to review. > > >> This is the code I have right now: > > >>http://pastie.org/1064629--> model > > >>http://pastie.org/1064637--> ExpenseForm > > >>http://pastie.org/1064644--> validator > > >>http://pastie.org/1064648--> CommentForm > > >> Considering I based my code from the example in the documentation, > >> something may be missing using Propel. > > >> And just when I thought I've figured it out, my tests start crashing! > >> I'm still trying to avoid my blank comment embed form to be saved into > >> the database. Whenever I save the ExpenseForm without comment, both > >> gets saved anyway! So perhaps something may be missing in my > >> saveEmbeddedForms() extension or perhaps on my custom validator :S > > >> I hope someone can lead me in the right direction > > >> 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<symfony-users%2bunsubscr...@googlegroups.com> > >> For more options, visit this group at > >>http://groups.google.com/group/symfony-users?hl=en -- 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