Hi,

currently I'm trying to build a contact form with embedded subforms
(1:n -> phone numbers, email-addresses,...).

I started using the $this->embededFormForeach-method like described
here:
http://blog.barros.ws/2009/01/01/using-embedformforeach-in-symfony-part-ii/

But it seems that this function doesn't support populating the
subforms with existing objects.

Now I started to build a workaround (ContactForm.class.php):

//build addresses subform
$n = sizeof($this->getObject()->Addresses);
if ($n === 0){ $n = 1; }
$addressForm = new sfForm();
for($i=0;$i<=$n;$i++){
  $addressForm->embedForm($i, new AddressForm($this->getObject()-
>Addresses[$i]));
}
$this->embedForm('addresses', $addressForm);


I seems to work, but it feels a bit overimplemented for me.

What do you think? Is this the "official" way for building 1:n-
subforms because embedFormForEach doesn't support editing subobjects
at the moment?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to