Say you need to generate a random password when creating new user:
class User extends AppModel
...
public function beforeSave() {
$this->data[$this->alias]['password'] =
AuthComponent::password(self::generatePassword());
return true;
}
}
and in the controller:
public function add() {
if ($this->request->isPost()) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__("The user has been
saved"));
$this->redirect(array('action' => 'index'));
How can I pass the clear text password (as returned by
generatePassword()) from the model to the template so the user can see
it? Thanks.
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php