Yii Framework Forum: ConfirmPassword - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

ConfirmPassword Property "User.PasswordConfirm" is not defined. Rate Topic: -----

#1 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 25 September 2009 - 04:30 AM

I try to build a user management system. for that i need a form to create a new user. it's working fine untill i build in a second password field "ConfirmPassword".

on submit i get the error: Property "User.PasswordConfirm" is not defined.

i think yii is giving me the error because the field doesn't exist in the database.

how can i get this working?

below the code:

User model:
    public function rules()
    {
        return array(
            array('GroupId, FirstName, LastName, Email, Username, Password, PasswordConfirm', 'required'),
            array('Email', 'email'),
            array('Password', 'compare', 'compareAttribute' => 'PasswordConfirm')
        );
    }

    public function safeAttributes()
    {
        return array('GroupId', 'FirstName', 'LastName', 'Email', 'Username', 'Password', 'PasswordConfirm');
    }


Piece of the form
        <li>
            <?php echo CHtml::Label('Nogmaals', 'User_PasswordConfirm'); ?>
            <?php echo CHtml::activePasswordField($user, 'PasswordConfirm', array('value' => '')); ?>
        </li>

0

#2 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 25 September 2009 - 05:00 AM

You may look here .
Posted Image
0

#3 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 25 September 2009 - 05:01 AM

Hi,

just add a public var to extend your model with this field:
public $PasswordConfirm;


Regards
1

#4 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 25 September 2009 - 05:04 AM

damnit, thats it! thanks yoshi

is it a good idea to declare you fieldname in the model everytime?
0

#5 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 25 September 2009 - 05:07 AM

another question: all the field exept the Email field doesn't get the class="error" attribute if the validation failed.

is this a bug?
0

#6 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 25 September 2009 - 05:55 AM

View Postbas_vdl, on 25 September 2009 - 05:04 AM, said:

is it a good idea to declare you fieldname in the model everytime?


Yes, you need to add these variables. Otherwise the model couln't 'know' these fields, because they don't belong to the db table.


View Postbas_vdl, on 25 September 2009 - 05:07 AM, said:

another question: all the field exept the Email field doesn't get the class="error" attribute if the validation failed.


Have you tried
array('Email', 'email', 'allowEmpty'=>false),


Regards
0

#7 User is offline   sensorario 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,987
  • Joined: 07-September 10
  • Location:Cesena (Italy)

Posted 10 March 2011 - 08:50 AM

Hi! And ... what we have to do if the field is a checkbox and we want that users check it!?
0

#8 User is offline   EdoFre 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 24-February 11
  • Location:Groningen, The Netherlands

Posted 10 March 2011 - 09:02 AM

View Postsensorario, on 10 March 2011 - 08:50 AM, said:

Hi! And ... what we have to do if the field is a checkbox and we want that users check it!?


You can use it in the rules as required if they need to check it, another way is to use the parameter checked on your checkbox, this way it's auto checked and users have to select or deselect it.

<?php echo $form->checkBox($model,'name',  array('checked'=>'checked')); ?>

Moi,
0

#9 User is offline   Tahir Yasin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 29-November 11

Posted 09 December 2011 - 12:37 AM

I followed this code, but the password and confirm password both are also required in updated case, what is the solution of this problem.

Please help me.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users