public function afterValidate() { if ($this->hasMultiSelectValue('assessment', 'Other')) { if (empty($this->other)) { $this->addError('other', 'Please enter details'); } } parent::afterValidate(); }
public function afterValidate() { if ($this->further_findings_assignment) { foreach ($this->further_findings_assignment as $assignment) { if (!$assignment->validate()) { foreach ($assignment->errors as $field => $errors) { $this->addError($field, $errors[0]); } } } } else { $this->addError('further_findings_assignment', 'Please select at least one finding'); } parent::afterValidate(); }
/** * Ensure a principal diagnosis is set for the episode. * */ public function afterValidate() { if (count($this->diagnoses)) { $principal = false; foreach ($this->diagnoses as $diagnosis) { if ($diagnosis->principal) { $principal = true; } } if (!$principal) { $this->addError('diagnoses', 'Principal diagnosis required.'); } } // This isn't very nice but there isn't a clean alternative at the moment $controller = \Yii::app()->getController(); if ($controller instanceof \BaseEventTypeController) { $et_diagnoses = \ElementType::model()->find('class_name=?', array('OEModule\\OphCiExamination\\models\\Element_OphCiExamination_Diagnoses')); $children = $controller->getChildElements($et_diagnoses); $have_further_findings = false; foreach ($controller->getChildElements($et_diagnoses) as $element) { if (\CHtml::modelName($element) == 'OEModule_OphCiExamination_models_Element_OphCiExamination_FurtherFindings') { $have_further_findings = true; } } if (!$have_further_findings && !$this->diagnoses) { $this->addError('diagnoses', 'Please select at least one diagnosis.'); } } parent::afterValidate(); }
public function afterValidate() { foreach (array('left', 'right') as $side) { foreach ($this->{$side . '_cvi_disorder_assignments'} as $ass) { // would prefer this to be just on the assignment validation, but having trouble // with scenario specification for different contexts (i.e. validating for errors to return // to the user versus actually saving (where the element id is requred) if ($ass->main_cause && !$ass->affected) { $this->addError('disorders', "{$side} disorder - '{$ass->ophcocvi_clinicinfo_disorder->name}'' cannot be main cause when eye not affected."); } } } parent::afterValidate(); }
/** * Validate prescription items. */ protected function afterValidate() { // Check that fields on prescription items are set foreach ($this->items as $i => $item) { if (!$item->validate()) { foreach ($item->getErrors() as $fld => $err) { $this->addError('items', 'Item (' . ($i + 1) . '): ' . implode(', ', $err)); } } } return parent::afterValidate(); }
protected function afterValidate() { if ($this->booking) { if ($this->consultant_required && !$this->booking->session->consultant) { $this->addError('consultant', 'The booked session does not have a consultant present, you must change the session or cancel the booking before making this change'); } if ($anaesthetic = AnaestheticType::model()->findByPk($this->anaesthetic_type_id)->name) { if (in_array($anaesthetic, array('LAC', 'LAS', 'GA')) && !$this->booking->session->anaesthetist) { $this->addError('anaesthetist', 'The booked session does not have an anaesthetist present, you must change the session or cancel the booking before making this change'); } if ($anaesthetic == 'GA' && !$this->booking->session->general_anaesthetic) { $this->addError('ga', 'General anaesthetic is not available for the booked session, you must change the session or cancel the booking before making this change'); } } } return parent::afterValidate(); }
protected function afterValidate() { if ($this->witness_required && strlen($this->witness_name) < 1) { $this->addError('witness_name', 'Witness name must be entered'); } if ($this->interpreter_required && strlen($this->interpreter_name) < 1) { $this->addError('interpreter_name', 'Interpreter name must be entered'); } return parent::afterValidate(); }