Hi,
I am created one project in which On 1.3 version of Phalcon code is working fine.My error Messages are show on screen. But when I try for 2.0 version for another Machine it is not showing error messages. I call It from View using
$form->messages("user_dob");
If I print this value in controller It display the value.
I used beforevalidation function while validation function that is :
if (isset($data['user_dob']) && $data['user_dob']!='') {
$elements['user_dob']->addValidators(array( new \Phalcon\Validation\Validator\Regex(
array(
'field' => 'user_dob',
'pattern' => '/[0-9]{2}\/[0-9]{2}\/[0-9]{4}/',
'message' => 'Invalid date format'
))
));
$dob = array_reverse(explode('/', $data['user_dob']));
$dob_nw = implode('-', $dob);
$now_dt = date_create(date('Y-m-d'));
$dob_dt = date_create($dob_nw);
$interval = date_diff($now_dt, $dob_dt);
$age = (int) $interval->format('%y');
//echo "test-->$age";exit;
if ( $age < USER_AGE_LIMIT) {
$elements['user_dob']->addValidators(array( new \Phalcon\Validation\Validator\Regex(
array(
'field' => 'user_dob',
'pattern' => '/[0-9]/',
'message' => 'Age shuld be greater than 18'
))
));
}
}
This code is used for chevk validation.
Please Help me to Solve this problem.