/** * Validate this form. */ public function validate() { if (I2CE_Validate::checkNumber($this->count, 1)) { if (!$this->code_start || !I2CE_Validate::checkNumber($this->code_start, 0)) { $this->setInvalidMessage('code_start', 'required'); } if ($this->code_format != "") { if (preg_match('/%[\\d\\.]*d/', $this->code_format) == 0) { $this->code_format .= "%d"; } $storage = I2CE_ModuleFactory::instance()->getClass("forms-storage"); if ($storage instanceof I2CE_FormStorage) { $count = $this->count; $code_start = $this->code_start; while ($count--) { $this->code = sprintf($this->code_format, $code_start); $storage->validate_formfield($this->getField("code")); if ($this->getField("code")->hasInvalid()) { $this->setInvalidMessage("code_format", 'unique'); } $code_start++; } } } } parent::validate(); }
/** * Run extra validation for the fields being edited. */ protected function validate() { parent::validate(); if ($this->post_exists('position_option') && $this->post('position_option') == 'create' && $this->new_position instanceof iHRIS_Position) { $this->new_position->validate(); } if ($this->isPost() && $this->old_position instanceof iHRIS_Position) { if ($this->getPrimary()->start_date->compare($this->old_person_position->start_date) != -1) { $this->getPrimary()->setInvalidMessage('start_date', 'bad_date'); } if (!$this->old_position->getField('status')->isValid()) { $this->old_position->setInvalidMessage('status', 'required'); } //I2CE::raiseMessage("in validate " . $this->old_position->getField('status')->getDBValue() ); if (!$this->old_person_position->getField('reason')->isValid()) { $this->old_person_position->setInvalidMessage('reason', 'required'); } } }