Hello,

Sorry, did not read well Euromak blog. There is being compared tothe 
password field with an auxiliary field of the form ("pwd") ....

Understanding that, I've solved with this code:


public function beforeSave() {
        parent::beforeSave($options);
        if(!empty($this->data[$this->alias]['*auxPassword*'])) {
                $this->data[$this->alias]['password'] = 
AuthComponent::password($this->data[$this->alias]['*auxPassword*']);
        
        }elseif(!isset($this->data[$this->alias]['*auxPassword*'])){
                $this->data[$this->alias]['password'] = 
AuthComponent::password($this->data[$this->alias]['password']);
        
        }else{
                //nothing, leave the password is in database
        }
        return true;
}

... and I leave the password field as not required, but does not allowempty 
strings (allowEmpty = false):


'password' => array(
        'required' => array(
                'rule' => array('notEmpty'),
                'message' => AppModel::MESSAGE_ERROR_MANDATORY,
                'allowEmpty' => false,
                'required' => false, /* Can not be empty but there is not 
obligatrío in the edit form (by example) */
        )
),


and I leave the edit form as:
                echo $this->Form->input('username');
//echo $this->Form->input('password');
*echo $this->Form->input('auxPassword', array(*
* 'type' => 'password',*
* 'label' => 'Password (leave blank for no update)' *
* ));*



Thank you very much for your comments. :)

El martes, 29 de mayo de 2012 18:38:03 UTC+2, AD7six escribió:


On Monday, 28 May 2012 21:20:13 UTC+2, lsri8088 wrote:
Hello,

I'm using cake 2.1 with AuthComponent and standard data modelusers.

How I can edit a user without changing the password?


Don't include the password field at all in the data you are saving.


AD

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to