tags:

views:

30

answers:

2

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
A: 

Try changing this line:

$profile->setsfGuardUser($user);

to

$profile->setSfGuardUser($user);

(note the capital S)

benlumley
I changed it but I still get the same error:
Ite Code
A: 

I see that the following two lines, do not match up with your schema file:

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

The setEmail should be setUserEmail. The setRemember doesn't exist in your schema.

EDIT

I guess the error message would be indicating that the following line is bad:

$profile->setsfGuardUser($user);

I'm not sure if you can do that or not though, settings a related model with a set method.

Jon
I changed but still getting the same error: Unknown record property / related component "sf_guard_user" on "sfGuardUserProfile"$profile = new sfGuardUserProfile(); $profile->setSfGuardUser($user); $profile->setUserEmail($this->getRequestParameter('user_email')); $profile->save();
Ite Code