2010-09-07 35 views
0

我在尝试实现此代码时遇到此错误。具有$ user的第一个代码块在数据库更新时似乎工作,但第二部分失败。这是错误:symfony sfGuard未知记录属性/相关组件“sf_guard_user”on“sfGuardUserProfile”

未知记录属性/相关组件“sfGuardUserProfile”“sf_guard_user”

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'); 
    } 

这里是我的用户配置文件的schema.yml:

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 

回答

0

我看到下面的两行,不要用你的架构文件匹配:

$profile->setEmail($this->getRequestParameter('user_email')); 
$profile->setRemember($this->getRequestParameter('remember', true)); 

的setEmail应setUserEmail。 setRemember在您的模式中不存在。

编辑

我猜的错误信息会被其后面的线路接触不良:

$profile->setsfGuardUser($user); 

我不知道,如果你能做到这一点与否,虽然,设置相关模型与一套方法。

+0

我改变,但仍然得到了同样的错误:在“sfGuardUserProfile” $配置=新sfGuardUserProfile()未知记录属性/相关组件“sf_guard_user”; $ profile-> setSfGuardUser($ user); $ profile-> setUserEmail($ this-> getRequestParameter('user_email')); $ profile-> save(); – 2010-09-08 13:15:57

0

尝试改变这行:

$profile->setsfGuardUser($user); 

$profile->setSfGuardUser($user); 

(注意是大写的S)

+0

我改变了,但我仍然得到同样的错误: – 2010-09-08 12:44:56