but it is! it is right there in the db.. isn't this interesting!
On Mar 16, 10:29 pm, Nathan Rzepecki <[email protected]>
wrote:
> That means it is not yet saved.
>
> ---------------------
> Nathan Rzepeckihttp://www.lionslair.net.au
>
> maestro wrote:
> > sadly $this->getObject()->getId() is returning a null in my case...
> > although the rest of the object values are there.
>
> > On Mar 16, 8:13 pm, Nathan Rzepecki <[email protected]>
> > wrote:
>
> >> It is this line here that does it.
>
> >> $entry->setServerId($this->getObject()->getId());
>
> >> within
>
> >> public function saveEmbeddedForms($con = null, $forms = null)
>
> >> Because by the time that is called the main object is then saved.
>
> >> ---------------------
> >> Nathan Rzepeckihttp://www.lionslair.net.au
>
> >> maestro wrote:
>
> >>> Still stuck!
>
> >>> Looking a the sfPropelForm save() it is clear that the call to
> >>> saveEmbeddedForms comes after the main object is getting saved. I see
> >>> it also happening in the log file. Could it be something to do with
> >>> the begin and transaction calls that surrounding doSave and
> >>> saveEmbeddedForms? I mean, maybe the id of the main object isn't
> >>> available until the db transaction gets committed. But, then am doing
> >>> the exact same thing else where and it is working fine.
>
> >>> hmm, need to take a break..
>
> >>> On Mar 16, 7:10 pm, lionslair <[email protected]> wrote:
>
> >>>> I finally cracked in. These two functions in my ServerForm class
>
> >>>> public function bind(array $taintedValues = null, array
> >>>> $taintedFiles = null)
> >>>> {
> >>>> $ret = parent::bind($taintedValues, $taintedFiles);
> >>>> foreach ($this->embeddedForms as $name => $form) {
> >>>> $this->embeddedForms[$name]->isBound = true;
> >>>> $this->embeddedForms[$name]->values = $this->values[$name];
> >>>> }
>
> >>>> return $ret;
> >>>> }
>
> >>>> public function saveEmbeddedForms($con = null, $forms = null)
> >>>> {
> >>>> foreach($this->getEmbeddedForms() as $closeForm)
> >>>> {
>
> >>>> $entry=$closeForm->save();
> >>>> $entry->setServerId($this->getObject()->getId());
> >>>> // mail('[email protected]', 'debug', print_r
> >>>> ($entry, true));
> >>>> $entry->save();
> >>>> }
> >>>> }
>
> >>>> On Mar 16, 12:42 am, justin_davis <[email protected]> wrote:
>
> >>>>> I'm doing something like this, and this is my solution:
>
> >>>>> Let's say you have two forms, one is an sfGuardUser form (Form 1), the
> >>>>> other is a Profile form (Form 2) (representing those two models).
> >>>>> When a new user is created, a new profile must be also created that
> >>>>> depends on that record (Profile depends on sfGuardUser):
>
> >>>>> (this is sfGuardUserForm.class.php):
>
> >>>>> $profileForm = new ProfileForm();
> >>>>>
> >>>>> $profileForm->getObject()->setsfGuardUserId($this->getObject());
> >>>>> $this->embedForm('profile', $profileForm);
>
> >>>>> You'll also want to unset the sfGuardUserId field: unset($profileForm
> >>>>> ['sf_guard_user_id']);
>
> >>>>> So, it's basically creating a ProfileForm, getting the object related
> >>>>> to it, then telling symfony to set that object's sfUserGuardId to
> >>>>> equal the sfGuardUser object that this class represents.
>
> >>>>> Does that make sense? Hope this helps. I'm somewhat of a newb
> >>>>> myself, so I may be telling you something that doesn't apply.
>
> >>>>> Good luck!
>
> >>>>> Justin
>
> >>>>> On Feb 5, 4:25 pm, Timmy <[email protected]> wrote:
>
> >>>>>> I have two forms form 1 and form 2. Form 2 is embedded into form 1. On
> >>>>>> save form1 must be saved as a new row and therefore recieving a
> >>>>>> primary key, Afterwards this foreign key needs to be injected into
> >>>>>> form 2 before it can save.
>
> >>>>>> The only way i have figured out at the mo is after the form is valid.
> >>>>>> Instantiate the two models, populate them, add form2 model to form 1
> >>>>>> model then save.
>
> >>>>>> Isn't there an easier way?
>
> >>>>>> Thanx
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---