$this->data in a model is NOT the same as $this->data in a
controller.  In a controller $this->data includes the submitted model
data from a form, in a model it is only the set() data that is about
to be saved.  When you use Model->saveField(), the only data set is
the field you are saving, so random form data will not be included.

The first case is your error, as you identified.  Of course you should
only process a field that is included (although perhaps validation can
care if a field is ignored).  But still, I don't think md5'ing every
time the model is saved is a good idea - you only want to md5 the
unhashed password from the user, and I imagine a lot of the time a
User is loaded and saved a fresh password is not included.  I would
recommend something more like

function beforeSave(){
     if ( isset($this->data['User']['new_password']) ){
          $this->data['User']['password'] = md5($this->data['User']
['new_password']);
     }
}



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to