I try to create a profile object with a sfGuardUser object
The shema of my profile (named affiliate) is :
job_affiliate:
id: ~
user_id: { type: integer, foreignTable: sf_guard_user,
foreignReference: id, required: true, onDelete: cascade, index: true }
and my process form in my action is :
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request-
>getFiles($form->getName()));
if ($form->isValid())
{
if ($form->getObject()->isNew()) {
$nom=$request->getParameter('job_affiliate[nom]');
$affiliate = $form->getObject();
$user = new sfGuardUser();
$algorithm='sha1';
$user->setPassword(call_user_func_array($algorithm, array
($nom)));
$user->setUsername($nom);
$user->save();
}
$job_affiliate = $form->save();
// how can i update the 'job_affiliate[user_id]' in the form
with the $user->getId() value
$this->redirect('affiliate/edit?id='.$job_affiliate->getId());
}
With this code i have an integrity error : "a foreign key constraint
fails " because the user_id is null.
How can i force the user_id with the $user->getId() value ?
Something like $form->setRequestAttibute($user->getId(),'job_affiliate
[user_id]'); ?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---