Browse Source

Merge pull request #1327 from pafuinlu/patch-2

Added a clear() function to Model.php (2.4 branch)
Mark Story 12 years ago
parent
commit
b2a40c787d
1 changed files with 11 additions and 0 deletions
  1. 11 0
      lib/Cake/Model/Model.php

+ 11 - 0
lib/Cake/Model/Model.php

@@ -1499,6 +1499,17 @@ class Model extends Object implements CakeEventListener {
 	}
 
 /**
+ * This function is a convenient wrapper class to create(false) and, as the name suggests, clears the id, data, and validation errors.
+ *
+ * @return always boolean TRUE upon success
+ * @see Model::create()
+ */
+	public function clear() {
+		$this->create(false);
+		return true;
+	}
+
+/**
  * Returns a list of fields from the database, and sets the current model
  * data (Model::$data) with the record found.
  *