When i was up against this i took a look at how sfGuard went about
embedding the user profile fields. IT actually doesnt use embedForm but
rather embedFields. What the preference is for one or the other and the
use case for each im not sure. Id suggest taking a look at how that
works. There are basically two methods it uses... a special getter for
the profile or "embeddedObject" and a getterto get the PRimaryKey field
name of the embedded object so that the field can be unset as needed.
Additionally, updateObject and updateDefaultsFromObject are overridden
to make sure that the embedded stuff is updated as well.
What i did was to extend the primary form because there were instances
when i would want to use it by itself. Then i added those methods with
some edits to give it the behavior i needed and didnt need (for example
the getPrimaryKey method wasnt really necessary since my embedded stuff
didnt need to be configurable, this name was always going to be static).
The challenge i came across was that my embeded fields/form utilized
many2many relationships. So what i did here was copy all the methods
from my embedded forms base class, then i edited those to make a call
to my special getter for the embeddedObject instead of the default
object. so in my save*List() methods:
...
$obj = new Relationship();
$obj->setRelatedId($this->object->getPrimaryKey());
...
BECAME
...
$obj = new Relationship();
$obj->setRelatedId($this->getEmbeddedObject()->getPrimaryKey());
...
In addition to this i had to refactor the doSave methods a bit as well.
I hope that helps.
Jonathan Franks wrote:
> I'm trying to embed propel forms inside another propel form like this...
>
> class ProductForm extends BaseProductForm
> {
> public function configure()
> {
> $polaroids = $this->getObject()->getPolaroids();
> foreach($polaroids AS $polaroid)
> {
> $pform = new PolaroidForm($polaroid);
> $this->embedForm($polaroid->getName(), $pform);
> }
> }
> }
>
> The form is displayed with the embedded forms.
>
> The main form fields are auto-populated but the fields of the embedded
> forms are not.
>
> What must I do to autopopulate the embedded forms??
>
> Thankyou in advance, Jonathan.
>
> >
--
Ant Cunningham
Graphic Designer | Web Developer
Vector Based Design
[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---