I have an issue with data validation.
I have model Administrator with fields : firstname,lastname,password
In Administrator model I set validation for every field (let's say
firstname can't be empty, lastname can't be empty and password can't
be empty and can consist only letters).
I want to define function which will allow user to edit (update)
Administrator's firstname and lastname. So in my function admin_edit:
function admin_edit($id) {
if(!empty($this->data)) {
$this->Administrator->set($this->data);
if($this->Administrator->validates()) {
//updating fields in DB
} else {
$this->validateErrors($this->Administrator);
}
}
}
In my view I have a form with two text fields: firstname and lastname.
I don't want password to be upadted.
And here's the problem: when I pass variables from form to admin_edit
function, validation function validates EVERY field in model
(firstname,lastname and password). And I only "give" function two
values: firstname and lastname; so the password - $this-
>data[Administrator][passowrd] - is empty and returns false from
validation.
How can I validate only firstname and lastname fields, without
validating password?
Any help appriciated. :-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment