Hello: I'm getting this error when I'm trying to implement this code. The first code block with $user seems to work as the database is updated, but the second part fails. This is the error:
Unknown record property / related component “sf_guard_user” on “sfGuardUserProfile”
public function executeCreateAccount()
{
$user = new sfGuardUser();
$user->setUsername($this->getRequestParameter('username'));
$user->setPassword($this->getRequestParameter('password'));
$user->setIsActive(false);
$user->save();
$profile = new sfGuardUserProfile();
$profile->setsfGuardUser($user);
$profile->setEmail($this->getRequestParameter('user_email'));
$profile->setRemember($this->getRequestParameter('remember', true));
$profile->save();
$this->getRequest()->setAttribute('user', $user);
$raw_email = $this->sendEmail('user', 'registrationConfirmation');
$this->logMessage($raw_email, 'debug');
$this->setFlash('user_email', $this->getRequestParameter('user_email'));
$this->redirect('user/askConfirmation');
}
Here is my schema.yml for the user profile:
sf_guard_user_profile:
columns:
id: { type: integer, primary: true, autoincrement: true }
user_id: { type: integer }
firstname: { type: string(255) }
lastname: { type: string(255) }
user_email: { type: string(255) }
relations:
sfGuardUser:
type: one
foreignType: one
class: sfGuardUser
local: user_id
foreign: id
onDelete: cascade
foreignAlias: Profile