user registration problem

I want to create a new user abd user password repeat but the model can not read the password_repeat

Since the password_repeat is at $_post, model can not read id

so I do

model


public $password_repeat;

...

  array('password_repeat', 'required', 'on'=>'newuser'),

array('usr_pass','compare', 'compareAttribute'=>'password_repeat', 'on'=>'newuser'),

..........

controller


...

 $model=new users;

          $type=$model->getTypeOptions();

        $model->scenario='newuser';

        // $model->setScenario('create');

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

        {//echo  $model->scenario;var_dump($_POST);die();

            $model->attributes=$_POST['users'];

           print_r($_POST);

           print_r( $model->attributes);...

form


 <?php  if ($update==false) { ?>

    <div class="simple">

        

      <?php     echo CHtml::activeLabelEx($model,'usr_pass'); ?>

      <?php echo CHtml::activePasswordField($model,'usr_pass'); ?>

    </div>

    <div class="simple"> <?php // echo $model->password_repeat; ?>

        <?php echo CHtml::activeLabelEx($model,'password_repeat'); ?>

        <?php echo CHtml::activePasswordField($model,'password_repeat',array('size'=>50,'maxlength'=>50)); ?>

    </div>

    <?php  }?>

I put also


... public function rules()

    {

        return array(

            array('usr_pass','length','max'=>64, 'min'=>6),

            array('password_repeat','length','max'=>64, 'min'=>6),...

 public function safeAttributes()

        {

                return array(

                        'usr_name, usr_pass,usr_type, password_repeat,user_surname,usr_email,usr_phone,usr_descr',

            

I can’t see what is wrong.

I quickly checked my files for my current project and the only stuff I have different are:

I don’t have "$type=$model->getTypeOptions();

    &#036;model-&gt;scenario='newuser';&quot;

You’re calling model->save() after $model->attributes=$_POST[‘users’];, right?

I had to set the scenario (newuser) at safeAttributes.\As i test it, it is ok

I have the same issue with the following code. The password_repeat field is posted but cannot be placed into the model attributes thru the

$model->attributes = $_POST[‘User’]; code line. FYI the action name is actionCreate. By saying scenario, do you mean action name? Am I doing anything wrong here?

class User extends CActiveRecord

{

public &#036;password_repeat;





...





public function safeAttributes()


{


    return array(


        'create'=&gt;'username, password, password_repeat',


    );


}	

}

I used


public function rules() {

        return array(

        array('usr_pass','length','max'=>64, 'min'=>6),

        array('password_repeat','length','max'=>64, 'min'=>6),  array('password_repeat', 'required', 'on'=>'newuser'),

        array('usr_pass','compare', 'compareAttribute'=>'password_repeat', 'on'=>'newuser'),

....

public function safeAttributes() {

        return array(

        parent::safeAttributes(),

        'newuser' =>  'usr_download,usr_name, usr_pass, password_repeat,usr_type,user_surname,usr_email,usr_phone,usr_descr',

        );

    }

....

I am doing same thing in my code but no password_repeat at all. I realized that the overriding the safeAttributes () has no effect on the $model->attributes. When I do print_r($model->attributes) the output is same with and without overriding the safeAttributes (). Any thoughts on this?

Thanks,

Ramin