Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

DateField: dmyfields set as required field in Form


Reply


2 Posts   923 Views

Avatar
Matze0681

Community Member, 25 Posts

23 November 2010 at 1:14pm

hi,

i am trying to add a splitted up DateField ( via $dob->setConfig('dateformat', 'dmy'); ) as a required field
in a Form. It seems like the default form validator can´t handle seperate day,month,year fields as required fields. Did anybody had the same problem ?

cheers
matze

Avatar
swaiba

Forum Moderator, 1808 Posts

2 December 2010 at 9:33pm

In short no, I've never come across, but how about creating your own validator? Something like...

class MyValidator extends RequiredFields {
   function php($data) {
      $bRet = parent::php($data);
      if (!customvalidation_fucntion($data['MyDate'])) {
         $obj->validationError('MyDate','MyDate must pass my validation',"required");
         $bRet = false;
      }
            
      return $bRet;
   }
}