Following thread will be useful information for you.
Problems with simple invalidate test
http://groups.google.com/group/cake-php/browse_thread/thread/354a677b21779c0/
"When *any* field is placed into invalid
status, a save operation will fail. However, if you update a field
using Model::set( ), any associated validation error is removed (the
data changes, we no longer know if it is invalid or not). When you
call Model::save( ) with parameters, those parameters are passed to
Model::set( ). " (by nate)
What about
if ($this->Module->save()) {
instead of
if ($this->Module->save($this->data)) {
?
Shun.D
http://cakephp.seesaa.net
On 8月24日, 午前8:49, rtanz <[EMAIL PROTECTED]> wrote:
> hi i have the following which my logic tells me should not save if a
> module with the same code is already saved in the database. Now when i
> test it i can see that it is finding a matching code and entering into
> the if ($this->Module->find($conditions) statement, and i assume
> therefore invalidating the code field. However it saves while as i was
> reading in the manual it is not supposed to save after i set the
> invalidate. so anyone knows what i might be doing wrong here? thanks
>
> function admin_add() {
> if (empty($this->data)) {
> $this->render();
> } else {
> $this->cleanUpFields();
> $module = $this->data['Module']['code'];
> $conditions = array("Module.code"=>"$module");
> if ($this->Module->find($conditions)) {
> $this->Module->invalidate('code');
> }
> if ($this->Module->save($this->data)) {
> $this->admin_createReview($this->Module->getLastInsertId(),
> $this->data['Module']['code'],$this->data['Module']
>
> ['name'],$this->data['Module']['year_delivered']);
> $this->Session->setFlash('The Module has been saved
> and an associated review created');
> $this->redirect('/admin/modules/index');
> } else {
> $this->Session->setFlash('Please correct errors
> below.');
> }
> }
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---