Validation for required date input
Permalink
Hi All,
I am having some issues validation that a date picker value is required. Please see the code below for an example:
Form item:
Controller Code:
The issue is that event when my date item has a value, the validator thinks it is empty
I am having some issues validation that a date picker value is required. Please see the code below for an example:
Form item:
Controller Code:
if ($this->isPost()) { $val = Loader::helper('validation/form'); $val->setData($_POST); $val->addRequired('eHeading', 'The event heading is required'); $val->addRequired('eDescription', 'The event description is required'); $val->addRequired('eDateStart', 'The event start date is required'); $val->addRequired('eDateEnd', 'The event end date is required'); if ($val->test()) { // submit for saving } else { $this->set('error', $val->getError()->getList() ); }
The issue is that event when my date item has a value, the validator thinks it is empty
...then view the source of the page to see a list of all the items in the POST array. Perhaps there's one that jumps out at you as being related to the datetime picker, and you should use that field's name instead for the validation code?