From e5d3364b268521e8541444b60ed1bddc16891783 Mon Sep 17 00:00:00 2001 From: Semenov Alexander Date: Wed, 25 Nov 2020 22:23:51 +0300 Subject: [PATCH] Update Select2.php --- src/Select2.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Select2.php b/src/Select2.php index 5b815bf..3b593f2 100644 --- a/src/Select2.php +++ b/src/Select2.php @@ -459,7 +459,14 @@ protected function isRequired() $validators = $this->model->getActiveValidators($this->attribute); foreach ($validators as $validator) { if ($validator instanceof RequiredValidator) { - return true; + if (is_callable($validator->when)) { + if (call_user_func($validator->when, $this->model, $this->attribute)) { + return true; + } + } else { + return true; + } + } } return false;