I'm more or less doing the same thing that Jonathan Wage recommended
doing in his article on extending sfDoctrineGuard with a profile
object, only I'm doing it in reverse. I have different entities which
each have a relation to the sfGuardUser object (eg., presenters who
can use the admin of the site, and end users who use the frontend of
the site). So I would like to have a create a presenter form, which
has the sfGuardUserForm embedded. Seems more or less like the use
case
that John described.
I went forth with his implementation.
1.  I added the relationship
relations:
    sfGuardUser:
      foreignType: one
2. After rebuilding the models and forms, I added the embedded form
to
my Presenter form
   parent::configure();
   $form = new sfGuardUserAdminForm($this->object->sfGuardUser);
   unset($form['id'], $form['presenter_id']);
   $this->embedForm('sfGuardUser', $form);
This works great, and I'm able to add a new presenter while adding a
new sfGuardUser at the same time.
Now when it comes to editing I have a problem.
First problem, I'm unsetting the primary key of sfGuardUser in the
form, so we fail on validation. To get around that, I just put in a
conditional logic, only unsetting that field if its a new form.
Now when I save the form, I lose the relation. This seems, at first,
because i'm unsetting the foreign key field. On closer inspection,
when I looked at the file for that form (BasesfGuardUserForm), that
field widget doesn't even exist!

After this I found the embedRelation method which seems to remove a
lot of this grunt work for me. Unfortunately, I'm still losing the
relationship when it saves.
What am I missing here?

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