Hi patter,

What I'd do is unset the embedded form as if ot was any other field.

if($postedValues[..insert your input name...]=='')
   unset($subForm['embededFormName'])


Do this from anywhere before you bind the data. You could also
override the bind method in your form, unset the form there, and call
the parent method.

Julien

On Feb 11, 11:06 am, patter <[email protected]> wrote:
> Hello,
>
> I have a 1:n relation: User have two phone numbers (well my real use
> case is a bit complicated :-) ).
>
> In my UserForm::configure() I have something like this:
>
> $p1 = $this->object['phones'][0] = new Phone();
> $p2 = $this->object['phones'][1] = new Phone();
>
> $subForm = new sfForm();
> $subForm->embedForm(0, new PhoneForm($p1 );
> $subForm->embedForm(1, new PhoneForm($p2));
>
> $this->embedForm('phones', $subForm);
>
> This works perfect. I can add a new User with 2 phones.
>
> The problem is that if the user doesn't provide information for second
> phone I should not insert a blank record (in fact I can't because of
> not null fields).
>
> I have read a lot of articles but I'm not able to find solution yet.
>
> I think that I have to use UpdateObject() method to remove unwanted
> relation, but if this is the better solution ?
>
> I use Doctrine :-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to