OEModule\OphCiExamination\models\Element_OphCiExamination_IntraocularPressure::afterValidate PHP Method

afterValidate() public method

public afterValidate ( )
    public function afterValidate()
    {
        foreach (array('right' => 'hasRight', 'left' => 'hasLeft') as $side => $checker) {
            if ($this->{$checker}()) {
                if ($this->{"{$side}_values"}) {
                    foreach ($this->{"{$side}_values"} as $value) {
                        if (!$value->validate()) {
                            foreach ($value->getErrors() as $field => $errors) {
                                foreach ($errors as $error) {
                                    $this->addError("{$side}_values.{$field}", $error);
                                }
                            }
                        }
                    }
                } else {
                    if (!$this->{"{$side}_comments"}) {
                        $this->addError("{$side}_comments", "Comments are required when no readings are recorded ({$side})");
                    }
                }
            }
        }
    }