I’m using this code in my action to register a new user:
public function register() {
$this->set('title_for_layout', 'Register');
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash('Your account has been created. You may now login with your username and password.', 'default', array('class' => 'success-flash'));
$this->redirect(array('action' => 'register'));
} else {
$this->Session->setFlash('There was an error creating your account.', 'default', array('class' => 'error-flash'));
}
}
}
However, the regisered field in my database users table is always 0000-00-00 00:00:00. How can I make Cake insert a correct date into this field? Thanks.
According to cakephp conventions the field should be named
created.Cakephp will then automatically fill that field.
It’s written at the bottom of that paragraph.
More detailed docs, but for the 1.3 version: docs.