|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | /** |
4 | | - * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2020 |
| 4 | + * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2021 |
5 | 5 | * @package yii2-widgets |
6 | 6 | * @subpackage yii2-widget-select2 |
7 | 7 | * @version 2.2.1 |
@@ -128,7 +128,8 @@ class Select2 extends InputWidget |
128 | 128 | * - `unselectLabel`: _string_, the markup to be shown to unselect all records. Defaults to: |
129 | 129 | * `<i class="glyphicon glyphicon-checked"></i> Unselect all`. |
130 | 130 | * - `selectOptions`: _array_, the HTML attributes for the container wrapping the select label. Defaults to `[]`. |
131 | | - * - `unselectOptions`: _array_, the HTML attributes for the container wrapping the unselect label. Defaults to `[]`. |
| 131 | + * - `unselectOptions`: _array_, the HTML attributes for the container wrapping the unselect label. Defaults to |
| 132 | + * `[]`. |
132 | 133 | * - `options`: _array_, the HTML attributes for the toggle button container. Defaults to: |
133 | 134 | * `['class' => 's2-togall-button']`. |
134 | 135 | */ |
@@ -458,15 +459,9 @@ protected function isRequired() |
458 | 459 | } |
459 | 460 | $validators = $this->model->getActiveValidators($this->attribute); |
460 | 461 | foreach ($validators as $validator) { |
461 | | - if ($validator instanceof RequiredValidator) { |
462 | | - if (is_callable($validator->when)) { |
463 | | - if (call_user_func($validator->when, $this->model, $this->attribute)) { |
464 | | - return true; |
465 | | - } |
466 | | - } else { |
467 | | - return true; |
468 | | - } |
469 | | - |
| 462 | + if ($validator instanceof RequiredValidator && (!is_callable($validator->when) || |
| 463 | + call_user_func($validator->when, $this->model, $this->attribute))) { |
| 464 | + return true; |
470 | 465 | } |
471 | 466 | } |
472 | 467 | return false; |
|
0 commit comments