2010-09-07 62 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