Thursday, September 13, 2012

Fatal Error on call to '$this->Session->setFlash'

G'day,

I do not understand how I induced this error:
'Error: Call to a member function setFlash() on a non-object'
which happens on any call to '$this->Session->setFlash' as noted in the default edit (or add) function below?

I was adding options to the related form (option lists, labels, titles) when I broke it and have been looking for misplaced or missing closing parens, braces, brackets, or commas with no luck. This is a bare-bones data-entry app with _nothing_ extra included other than the DebugKit plugin. I did notice that even though the flash message fails the changes made by editing or adding a record _are_ correctly saved to the db and displayed in the index view when refreshed.

Any hints on where to look next will be greatly appreciated.

MTIA, McS

public function edit($id = null) {
$this->Batch->id = $id;
if (!$this->Batch->exists()) {
throw new NotFoundException('Invalid batch');
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->Batch->save($this->request->data)) {
$this->Session->setFlash('The batch has been saved'); /*this line*/
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash('The batch could not be saved. Please, try again.'); /*this line*/
}
} else {
$this->request->data = $this->Batch->read(null, $id);
}
} // end edit($id = null)

--
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate