Hi All,
is there a way to manually reset/delete all validation messages that are already generated?
What I have found is that invoking validation() method several times multiply number of generated messages. On the other hand invoking create() method cause reseting/deleting all messages.
My model with 2 validators:
class Customers extends \Phalcon\Mvc\Model {
public function validation() {
$this->validate(new PresenceOf(array(
'field' => 'country',
'message' => "My individual message!"
)));
$this->validate(new InclusionIn(
array(
"field" => "country",
"domain" => array("sk","cz"),
'message' => "Wrong country."
)
));
return $this->validationHasFailed() != true;
}
}
My controller:
$customer = new Customers();
$customer->validation();
//at the time there are 2 messages generated (one message for each validator)
$customer->validation();
$customer->validation();
$customer->validation();
//at the time there are 8 messages generated
$customer->create(); //this method reset messages and performs new validation
//at the moment there is only one message ("country is required")
$customer->validation();
/*at the moment there are 3 messages:
"country is required"
"My individual message!"
"Wrong country."
*/
At the end I would like to have in the array only last 2 messages - I mean those performed in the last validation().
TIA