OEModule\OphCiExamination\models\Element_OphCiExamination_InjectionManagementComplex::requiredIfTreatment PHP Method

requiredIfTreatment() public method

simple wrapper around requiredIfSide that checks the no treatment status flag before checking the side required attribute.
public requiredIfTreatment ( string $attribute, array $params )
$attribute string
$params array
    public function requiredIfTreatment($attribute, $params)
    {
        $side = $params['side'];
        if ($side == 'left' && $this->eye_id != \Eye::RIGHT || $side == 'right' && $this->eye_id != \Eye::LEFT) {
            if (!$this->{$side . '_no_treatment'} && $this->{$attribute} == null) {
                $this->addError($attribute, ucfirst($side) . ' ' . $this->getAttributeLabel($attribute) . ' must be provided when treatment required');
            }
        }
    }