Permalink
Browse files

BUGFIX: Don't clear form messages unless forTemplate() is actually ca…

…lled.

BUGFIX: Clear session-stored form data as well as form error message.
  • Loading branch information...
1 parent abbee41 commit 729bcc95db06d554ff60f5984cf2f9b840898a24 @sminnee sminnee committed Aug 31, 2011
Showing with 10 additions and 5 deletions.
  1. +10 −5 forms/Form.php
View
@@ -974,9 +974,7 @@ public function FieldMap() {
*/
public function Message() {
$this->getMessageFromSession();
- $message = $this->message;
- $this->clearMessage();
- return $message;
+ return $this->message;
}
/**
@@ -993,8 +991,6 @@ protected function getMessageFromSession() {
}else{
$this->message = Session::get("FormInfo.{$this->FormName()}.formError.message");
$this->messageType = Session::get("FormInfo.{$this->FormName()}.formError.type");
-
- Session::clear("FormInfo.{$this->FormName()}");
}
}
@@ -1030,9 +1026,11 @@ public function clearMessage() {
$this->message = null;
Session::clear("FormInfo.{$this->FormName()}.errors");
Session::clear("FormInfo.{$this->FormName()}.formError");
+ Session::clear("FormInfo.{$this->FormName()}.data");
}
public function resetValidation() {
Session::clear("FormInfo.{$this->FormName()}.errors");
+ Session::clear("FormInfo.{$this->FormName()}.data");
}
/**
@@ -1317,6 +1315,13 @@ public function forTemplate() {
(array)$this->getTemplate(),
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;
}
/**

0 comments on commit 729bcc9

Please sign in to comment.