Tu as pris le problème dans le mauvais sens
login.ctp
<?php
//formulaire de connexion
echo $this->Form->create('User');
echo $this->Form->input('mail');
echo $this->Form->input('password');
echo $this->Form->hidden('is_login',array('value'=>true));
echo $this->Form->submit('Connexion');
echo $this->Form->end();
?>
<?php
//formulaire d'enregistrement
echo $this->Form->create('User');
echo $this->Form->input('username');
echo $this->Form->input('mail');
echo $this->Form->input('password1');
echo $this->Form->input('password2');
echo $this->Form->hidden('is_register',array('value'=>true));
echo $this->Form->submit('Créer mon compte');
echo $this->Form->end();
?>
UsersController.php
public function login() {
if ($this->request->is('post')) {
if ($this->request->data'User']'is_login']) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash('Identifiant ou mot de passe incorect');
}
}
if ($this->request->data'User']'is_register']) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash('Nouveau compte créée');
} else {
$this->Session->setFlash('Votre compte n\'a pas pu être enregistré');
}
}
}
}