I've used
validate()
in the past. I have a page type where I have 'StartDate' => 'Date'
as a db field. I have the following validation method:
/**
* @return ValidationResult
*/
public function validate()
{
$result = parent::validate();
if ($this->ID > 0 && !$this->StartDate) {
$result->error('Start Date is required');
}
return $result;
}
I can create the page as
$this->ID > 0
works properly, but then after the initial creation, when StartDate
is a valid date (using the date popup of the DateField) and I attempt to save the page, it throws the validation exception. Has anyone else come across this type of behavior?
Thanks