$model -> attributes != $_POST['model'] - Why?

hello,

So I have my model ($user) which I’m trying to update through a form. And for some reason, when I set $user -> attributes = $_POST[‘User’]; the model’s attributes don’t change …

Maybe my logic is broken somewhere!?




$user_id = $_GET[ 'id' ];

$user = User::model() -> findByPk( $user_id );


if( isset( $_POST[ 'User' ] ) )

{

    var_dump( $_POST[ 'User' ] );

    $user -> attributes = $_POST[ 'User' ];

    echo '<br />';

    // so I expect this to be the same as $_POST['User'], but it's not :/

    var_dump( $user -> attributes );

    

    // this will always PASS (ie. required username!?)    

    if( $user -> validate() )

    {

                ;

    }


    // this is ALWAYS empty

    var_dump( $user->getErrors() );

    exit();

}



“I feel like I’m taking crazy-pills” :)

thanks,

–iM

little update, check this out:




  // still doesn't work

  $user -> setAttributes( $_POST['User'] );

  

  // but this does!

  $user -> setAttribute( 'username', $_POST['User']['username'] );



AAA!

Is it because I’m messing around with the [b]users[/b] table?

–iM

maybe you have to check your user::saveAttributes() method?!?




public function saveAttributes() {

    return array('username','email',...);

}