Reputation: 691
how can I do this?
I'm trying:
$this->form->getObject()->setWebsiteid($website);
$this->form->setDefault('websiteid', $website);
$request->setParameter('websiteid', $website);
none from above doesn't work
my code:
$this->form = new sfGuardRegisterForm();
if ($request->isMethod('post'))
{
$website=new Website();
$website->save();
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid())
{
/* here I try do that */
$this->form->getObject()->setWebsiteid($website);
/* here I try do that end */
$user = $this->form->save();
$this->getUser()->signIn($user);
$this->redirect('@homepage');
}
}
Upvotes: 1
Views: 3876
Reputation: 22756
Is websiteid
part of your User
model ?
Do you use the widget of websiteid
in your form ?
You can add the value after the save:
$user = $this->form->save();
$user->setWebsiteid($website);
$user->save();
But the first solution seems ok to me..
Upvotes: 1