BUGFIX: Don't clear form messages unless forTemplate() is actually called.

BUGFIX: Clear session-stored form data as well as form error message.
This commit is contained in:
Sam Minnee 2011-08-31 18:19:20 +12:00
parent abbee41b78
commit 729bcc95db

View File

@ -974,9 +974,7 @@ class Form extends RequestHandler {
*/ */
public function Message() { public function Message() {
$this->getMessageFromSession(); $this->getMessageFromSession();
$message = $this->message; return $this->message;
$this->clearMessage();
return $message;
} }
/** /**
@ -993,8 +991,6 @@ class Form extends RequestHandler {
}else{ }else{
$this->message = Session::get("FormInfo.{$this->FormName()}.formError.message"); $this->message = Session::get("FormInfo.{$this->FormName()}.formError.message");
$this->messageType = Session::get("FormInfo.{$this->FormName()}.formError.type"); $this->messageType = Session::get("FormInfo.{$this->FormName()}.formError.type");
Session::clear("FormInfo.{$this->FormName()}");
} }
} }
@ -1030,9 +1026,11 @@ class Form extends RequestHandler {
$this->message = null; $this->message = null;
Session::clear("FormInfo.{$this->FormName()}.errors"); Session::clear("FormInfo.{$this->FormName()}.errors");
Session::clear("FormInfo.{$this->FormName()}.formError"); Session::clear("FormInfo.{$this->FormName()}.formError");
Session::clear("FormInfo.{$this->FormName()}.data");
} }
public function resetValidation() { public function resetValidation() {
Session::clear("FormInfo.{$this->FormName()}.errors"); Session::clear("FormInfo.{$this->FormName()}.errors");
Session::clear("FormInfo.{$this->FormName()}.data");
} }
/** /**
@ -1317,6 +1315,13 @@ class Form extends RequestHandler {
(array)$this->getTemplate(), (array)$this->getTemplate(),
array('Form') array('Form')
)); ));
// Now that we're rendered, clear message
Session::clear("FormInfo.{$this->FormName()}.errors");
Session::clear("FormInfo.{$this->FormName()}.formError");
Session::clear("FormInfo.{$this->FormName()}.data");
return $result;
} }
/** /**