public function beforeValidate() { if ($this->witness_enabled) { if ($this->anaesthetist_id == 3) { if (!$this->anaesthetic_witness_id) { $this->addError('anaesthetic_witness_id', 'Please select a witness'); } } } return parent::beforeValidate(); }