Hi,
strange behaviour I got in my register-form. I have a form that collect
some basic data:
Sourcecode: <form id="UsersAddForm" method="post" action="/rosi/users/add">
when I submit the form, the output of print_r($this->data) is the following:
Array
(
[Users] => Array
(
[title] => Mr
[firstname] => test
[surname] => the
[email] => hello
[username] => world
[password] => application
[password_confirm] => stuff
)
)
Now the application goes into the Users/add action.
Here I use the baked version:
function add() {
if (!empty($this->data)) {
$this->User->create();
if ($this->User->save($this->data)) {
$this->Session->setFlash(__('The User has been saved',
true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The User could not be
saved. Please, try again.', true, array(), 'register'));
}
}
}
Now I have some validation in my Model user.php:
class User extends AppModel {
var $name = 'User';
var $validate = array(
'firstname' => 'alphanumeric',
'surname' => 'alphanumeric',
'email' => 'email',
'username' => 'alphanumeric',
'password' => 'alphanumeric'
);
}
Now I would expect the application to NOT save the data, because e.g.
the email address ist not valid. But it passes the save action and
creates an empty record in the database (except for id, created and
modified columns). The columns in the database are named exactly as in
the form.
So why is cakePHP saying that the invalid data is valid and tries to
save it. But even the saving of the data does not work, because he does
not save the valid nor the invalid fields.
Thanks a lot for your help.
Best regards,
Roman
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---