This is the rule I have, but it does not work:
$validator
->add('end_date', 'comparison', [
'rule' => ['comparison', 'end_date', '>', 'start_date']
])
I want to show that the final date is greater than the initial date
This is the rule I have, but it does not work:
$validator
->add('end_date', 'comparison', [
'rule' => ['comparison', 'end_date', '>', 'start_date']
])
I want to show that the final date is greater than the initial date
As I would do:
in the buildRules of the table would add the following rule, which calls a function that passes the two properties of the entity as a parameter.
$rules->add(function ($entity) {
return $this->dateComparison($entity->end_date, $entity->start_date);
}, 'dateComparison', [
'errorField' => 'end_date',
'message' => __('Is not greater than start date')
]);
Here is the function you would call:
public function dateComparison($startDate, $endDate)
{
if($startDate > $endDate){
return true;
}
return false;
}