Complex classes like ActiveField often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ActiveField, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
26 | class ActiveField extends Component |
||
27 | { |
||
28 | /** |
||
29 | * @var ActiveForm the form that this field is associated with. |
||
30 | */ |
||
31 | public $form; |
||
32 | /** |
||
33 | * @var Model the data model that this field is associated with. |
||
34 | */ |
||
35 | public $model; |
||
36 | /** |
||
37 | * @var string the model attribute that this field is associated with. |
||
38 | */ |
||
39 | public $attribute; |
||
40 | /** |
||
41 | * @var array the HTML attributes (name-value pairs) for the field container tag. |
||
42 | * The values will be HTML-encoded using [[Html::encode()]]. |
||
43 | * If a value is `null`, the corresponding attribute will not be rendered. |
||
44 | * The following special options are recognized: |
||
45 | * |
||
46 | * - `tag`: the tag name of the container element. Defaults to `div`. Setting it to `false` will not render a container tag. |
||
47 | * See also [[\yii\helpers\Html::tag()]]. |
||
48 | * |
||
49 | * If you set a custom `id` for the container element, you may need to adjust the [[$selectors]] accordingly. |
||
50 | * |
||
51 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
52 | */ |
||
53 | public $options = ['class' => 'form-group']; |
||
54 | /** |
||
55 | * @var string the template that is used to arrange the label, the input field, the error message and the hint text. |
||
56 | * The following tokens will be replaced when [[render()]] is called: `{label}`, `{input}`, `{error}` and `{hint}`. |
||
57 | */ |
||
58 | public $template = "{label}\n{input}\n{hint}\n{error}"; |
||
59 | /** |
||
60 | * @var array the default options for the input tags. The parameter passed to individual input methods |
||
61 | * (e.g. [[textInput()]]) will be merged with this property when rendering the input tag. |
||
62 | * |
||
63 | * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
||
64 | * |
||
65 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
66 | */ |
||
67 | public $inputOptions = ['class' => 'form-control']; |
||
68 | /** |
||
69 | * @var array the default options for the error tags. The parameter passed to [[error()]] will be |
||
70 | * merged with this property when rendering the error tag. |
||
71 | * The following special options are recognized: |
||
72 | * |
||
73 | * - `tag`: the tag name of the container element. Defaults to `div`. Setting it to `false` will not render a container tag. |
||
74 | * See also [[\yii\helpers\Html::tag()]]. |
||
75 | * - `encode`: whether to encode the error output. Defaults to `true`. |
||
76 | * |
||
77 | * If you set a custom `id` for the error element, you may need to adjust the [[$selectors]] accordingly. |
||
78 | * |
||
79 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
80 | */ |
||
81 | public $errorOptions = ['class' => 'help-block']; |
||
82 | /** |
||
83 | * @var array the default options for the label tags. The parameter passed to [[label()]] will be |
||
84 | * merged with this property when rendering the label tag. |
||
85 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
86 | */ |
||
87 | public $labelOptions = ['class' => 'control-label']; |
||
88 | /** |
||
89 | * @var array the default options for the hint tags. The parameter passed to [[hint()]] will be |
||
90 | * merged with this property when rendering the hint tag. |
||
91 | * The following special options are recognized: |
||
92 | * |
||
93 | * - `tag`: the tag name of the container element. Defaults to `div`. Setting it to `false` will not render a container tag. |
||
94 | * See also [[\yii\helpers\Html::tag()]]. |
||
95 | * |
||
96 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
97 | */ |
||
98 | public $hintOptions = ['class' => 'hint-block']; |
||
99 | /** |
||
100 | * @var bool whether to enable client-side data validation. |
||
101 | * If not set, it will take the value of [[ActiveForm::enableClientValidation]]. |
||
102 | */ |
||
103 | public $enableClientValidation; |
||
104 | /** |
||
105 | * @var bool whether to enable AJAX-based data validation. |
||
106 | * If not set, it will take the value of [[ActiveForm::enableAjaxValidation]]. |
||
107 | */ |
||
108 | public $enableAjaxValidation; |
||
109 | /** |
||
110 | * @var bool whether to perform validation when the value of the input field is changed. |
||
111 | * If not set, it will take the value of [[ActiveForm::validateOnChange]]. |
||
112 | */ |
||
113 | public $validateOnChange; |
||
114 | /** |
||
115 | * @var bool whether to perform validation when the input field loses focus. |
||
116 | * If not set, it will take the value of [[ActiveForm::validateOnBlur]]. |
||
117 | */ |
||
118 | public $validateOnBlur; |
||
119 | /** |
||
120 | * @var bool whether to perform validation while the user is typing in the input field. |
||
121 | * If not set, it will take the value of [[ActiveForm::validateOnType]]. |
||
122 | * @see validationDelay |
||
123 | */ |
||
124 | public $validateOnType; |
||
125 | /** |
||
126 | * @var int number of milliseconds that the validation should be delayed when the user types in the field |
||
127 | * and [[validateOnType]] is set `true`. |
||
128 | * If not set, it will take the value of [[ActiveForm::validationDelay]]. |
||
129 | */ |
||
130 | public $validationDelay; |
||
131 | /** |
||
132 | * @var array the jQuery selectors for selecting the container, input and error tags. |
||
133 | * The array keys should be `container`, `input`, and/or `error`, and the array values |
||
134 | * are the corresponding selectors. For example, `['input' => '#my-input']`. |
||
135 | * |
||
136 | * The container selector is used under the context of the form, while the input and the error |
||
137 | * selectors are used under the context of the container. |
||
138 | * |
||
139 | * You normally do not need to set this property as the default selectors should work well for most cases. |
||
140 | */ |
||
141 | public $selectors = []; |
||
142 | /** |
||
143 | * @var array different parts of the field (e.g. input, label). This will be used together with |
||
144 | * [[template]] to generate the final field HTML code. The keys are the token names in [[template]], |
||
145 | * while the values are the corresponding HTML code. Valid tokens include `{input}`, `{label}` and `{error}`. |
||
146 | * Note that you normally don't need to access this property directly as |
||
147 | * it is maintained by various methods of this class. |
||
148 | */ |
||
149 | public $parts = []; |
||
150 | /** |
||
151 | * @var bool adds aria HTML attributes `aria-required` and `aria-invalid` for inputs |
||
152 | * @since 2.0.11 |
||
153 | */ |
||
154 | public $addAriaAttributes = true; |
||
155 | |||
156 | /** |
||
157 | * @var string this property holds a custom input id if it was set using [[inputOptions]] or in one of the |
||
158 | * `$options` parameters of the `input*` methods. |
||
159 | */ |
||
160 | private $_inputId; |
||
161 | /** |
||
162 | * @var bool if "for" field label attribute should be skipped. |
||
163 | */ |
||
164 | private $_skipLabelFor = false; |
||
165 | |||
166 | /** |
||
167 | * PHP magic method that returns the string representation of this object. |
||
168 | * @return string the string representation of this object. |
||
169 | */ |
||
170 | 4 | public function __toString() |
|
181 | |||
182 | /** |
||
183 | * Renders the whole field. |
||
184 | * This method will generate the label, error tag, input tag and hint tag (if any), and |
||
185 | * assemble them into HTML according to [[template]]. |
||
186 | * @param string|callable $content the content within the field container. |
||
187 | * If `null` (not set), the default methods will be called to generate the label, error tag and input tag, |
||
188 | * and use them as the content. |
||
189 | * If a callable, it will be called to generate the content. The signature of the callable should be: |
||
190 | * |
||
191 | * ```php |
||
192 | * function ($field) { |
||
193 | * return $html; |
||
194 | * } |
||
195 | * ``` |
||
196 | * |
||
197 | * @return string the rendering result. |
||
198 | */ |
||
199 | 9 | public function render($content = null) |
|
221 | |||
222 | /** |
||
223 | * Renders the opening tag of the field container. |
||
224 | * @return string the rendering result. |
||
225 | */ |
||
226 | 13 | public function begin() |
|
251 | |||
252 | /** |
||
253 | * Renders the closing tag of the field container. |
||
254 | * @return string the rendering result. |
||
255 | */ |
||
256 | 10 | public function end() |
|
260 | |||
261 | /** |
||
262 | * Generates a label tag for [[attribute]]. |
||
263 | * @param null|string|false $label the label to use. If `null`, the label will be generated via [[Model::getAttributeLabel()]]. |
||
264 | * If `false`, the generated field will not contain the label part. |
||
265 | * Note that this will NOT be [[Html::encode()|encoded]]. |
||
266 | * @param null|array $options the tag options in terms of name-value pairs. It will be merged with [[labelOptions]]. |
||
267 | * The options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded |
||
268 | * using [[Html::encode()]]. If a value is `null`, the corresponding attribute will not be rendered. |
||
269 | * @return $this the field object itself. |
||
270 | */ |
||
271 | 11 | public function label($label = null, $options = []) |
|
291 | |||
292 | /** |
||
293 | * Generates a tag that contains the first validation error of [[attribute]]. |
||
294 | * Note that even if there is no validation error, this method will still return an empty error tag. |
||
295 | * @param array|false $options the tag options in terms of name-value pairs. It will be merged with [[errorOptions]]. |
||
296 | * The options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded |
||
297 | * using [[Html::encode()]]. If this parameter is `false`, no error tag will be rendered. |
||
298 | * |
||
299 | * The following options are specially handled: |
||
300 | * |
||
301 | * - `tag`: this specifies the tag name. If not set, `div` will be used. |
||
302 | * See also [[\yii\helpers\Html::tag()]]. |
||
303 | * |
||
304 | * If you set a custom `id` for the error element, you may need to adjust the [[$selectors]] accordingly. |
||
305 | * @see $errorOptions |
||
306 | * @return $this the field object itself. |
||
307 | */ |
||
308 | 9 | public function error($options = []) |
|
319 | |||
320 | /** |
||
321 | * Renders the hint tag. |
||
322 | * @param string|bool $content the hint content. |
||
323 | * If `null`, the hint will be generated via [[Model::getAttributeHint()]]. |
||
324 | * If `false`, the generated field will not contain the hint part. |
||
325 | * Note that this will NOT be [[Html::encode()|encoded]]. |
||
326 | * @param array $options the tag options in terms of name-value pairs. These will be rendered as |
||
327 | * the attributes of the hint tag. The values will be HTML-encoded using [[Html::encode()]]. |
||
328 | * |
||
329 | * The following options are specially handled: |
||
330 | * |
||
331 | * - `tag`: this specifies the tag name. If not set, `div` will be used. |
||
332 | * See also [[\yii\helpers\Html::tag()]]. |
||
333 | * |
||
334 | * @return $this the field object itself. |
||
335 | */ |
||
336 | 12 | public function hint($content, $options = []) |
|
351 | |||
352 | /** |
||
353 | * Renders an input tag. |
||
354 | * @param string $type the input type (e.g. `text`, `password`) |
||
355 | * @param array $options the tag options in terms of name-value pairs. These will be rendered as |
||
356 | * the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]]. |
||
357 | * |
||
358 | * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
||
359 | * |
||
360 | * @return $this the field object itself. |
||
361 | */ |
||
362 | 2 | public function input($type, $options = []) |
|
371 | |||
372 | /** |
||
373 | * Renders a text input. |
||
374 | * This method will generate the `name` and `value` tag attributes automatically for the model attribute |
||
375 | * unless they are explicitly specified in `$options`. |
||
376 | * @param array $options the tag options in terms of name-value pairs. These will be rendered as |
||
377 | * the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]]. |
||
378 | * |
||
379 | * The following special options are recognized: |
||
380 | * |
||
381 | * - `maxlength`: int|bool, when `maxlength` is set `true` and the model attribute is validated |
||
382 | * by a string validator, the `maxlength` option will take the value of [[\yii\validators\StringValidator::max]]. |
||
383 | * This is available since version 2.0.3. |
||
384 | * |
||
385 | * Note that if you set a custom `id` for the input element, you may need to adjust the value of [[selectors]] accordingly. |
||
386 | * |
||
387 | * @return $this the field object itself. |
||
388 | */ |
||
389 | 9 | public function textInput($options = []) |
|
398 | |||
399 | /** |
||
400 | * Renders a hidden input. |
||
401 | * |
||
402 | * Note that this method is provided for completeness. In most cases because you do not need |
||
403 | * to validate a hidden input, you should not need to use this method. Instead, you should |
||
404 | * use [[\yii\helpers\Html::activeHiddenInput()]]. |
||
405 | * |
||
406 | * This method will generate the `name` and `value` tag attributes automatically for the model attribute |
||
407 | * unless they are explicitly specified in `$options`. |
||
408 | * @param array $options the tag options in terms of name-value pairs. These will be rendered as |
||
409 | * the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]]. |
||
410 | * |
||
411 | * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
||
412 | * |
||
413 | * @return $this the field object itself. |
||
414 | */ |
||
415 | 1 | public function hiddenInput($options = []) |
|
423 | |||
424 | /** |
||
425 | * Renders a password input. |
||
426 | * This method will generate the `name` and `value` tag attributes automatically for the model attribute |
||
427 | * unless they are explicitly specified in `$options`. |
||
428 | * @param array $options the tag options in terms of name-value pairs. These will be rendered as |
||
429 | * the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]]. |
||
430 | * |
||
431 | * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
||
432 | * |
||
433 | * @return $this the field object itself. |
||
434 | */ |
||
435 | public function passwordInput($options = []) |
||
444 | |||
445 | /** |
||
446 | * Renders a file input. |
||
447 | * This method will generate the `name` and `value` tag attributes automatically for the model attribute |
||
448 | * unless they are explicitly specified in `$options`. |
||
449 | * @param array $options the tag options in terms of name-value pairs. These will be rendered as |
||
450 | * the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]]. |
||
451 | * |
||
452 | * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
||
453 | * |
||
454 | * @return $this the field object itself. |
||
455 | */ |
||
456 | 1 | public function fileInput($options = []) |
|
472 | |||
473 | /** |
||
474 | * Renders a text area. |
||
475 | * The model attribute value will be used as the content in the textarea. |
||
476 | * @param array $options the tag options in terms of name-value pairs. These will be rendered as |
||
477 | * the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]]. |
||
478 | * |
||
479 | * If you set a custom `id` for the textarea element, you may need to adjust the [[$selectors]] accordingly. |
||
480 | * |
||
481 | * @return $this the field object itself. |
||
482 | */ |
||
483 | public function textarea($options = []) |
||
492 | |||
493 | /** |
||
494 | * Renders a radio button. |
||
495 | * This method will generate the `checked` tag attribute according to the model attribute value. |
||
496 | * @param array $options the tag options in terms of name-value pairs. The following options are specially handled: |
||
497 | * |
||
498 | * - `uncheck`: string, the value associated with the uncheck state of the radio button. If not set, |
||
499 | * it will take the default value `0`. This method will render a hidden input so that if the radio button |
||
500 | * is not checked and is submitted, the value of this attribute will still be submitted to the server |
||
501 | * via the hidden input. If you do not want any hidden input, you should explicitly set this option as `null`. |
||
502 | * - `label`: string, a label displayed next to the radio button. It will NOT be HTML-encoded. Therefore you can pass |
||
503 | * in HTML code such as an image tag. If this is coming from end users, you should [[Html::encode()|encode]] it to prevent XSS attacks. |
||
504 | * When this option is specified, the radio button will be enclosed by a label tag. If you do not want any label, you should |
||
505 | * explicitly set this option as `null`. |
||
506 | * - `labelOptions`: array, the HTML attributes for the label tag. This is only used when the `label` option is specified. |
||
507 | * |
||
508 | * The rest of the options will be rendered as the attributes of the resulting tag. The values will |
||
509 | * be HTML-encoded using [[Html::encode()]]. If a value is `null`, the corresponding attribute will not be rendered. |
||
510 | * |
||
511 | * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
||
512 | * |
||
513 | * @param bool $enclosedByLabel whether to enclose the radio within the label. |
||
514 | * If `true`, the method will still use [[template]] to layout the radio button and the error message |
||
515 | * except that the radio is enclosed by the label tag. |
||
516 | * @return $this the field object itself. |
||
517 | */ |
||
518 | public function radio($options = [], $enclosedByLabel = true) |
||
539 | |||
540 | /** |
||
541 | * Renders a checkbox. |
||
542 | * This method will generate the `checked` tag attribute according to the model attribute value. |
||
543 | * @param array $options the tag options in terms of name-value pairs. The following options are specially handled: |
||
544 | * |
||
545 | * - `uncheck`: string, the value associated with the uncheck state of the radio button. If not set, |
||
546 | * it will take the default value `0`. This method will render a hidden input so that if the radio button |
||
547 | * is not checked and is submitted, the value of this attribute will still be submitted to the server |
||
548 | * via the hidden input. If you do not want any hidden input, you should explicitly set this option as `null`. |
||
549 | * - `label`: string, a label displayed next to the checkbox. It will NOT be HTML-encoded. Therefore you can pass |
||
550 | * in HTML code such as an image tag. If this is coming from end users, you should [[Html::encode()|encode]] it to prevent XSS attacks. |
||
551 | * When this option is specified, the checkbox will be enclosed by a label tag. If you do not want any label, you should |
||
552 | * explicitly set this option as `null`. |
||
553 | * - `labelOptions`: array, the HTML attributes for the label tag. This is only used when the `label` option is specified. |
||
554 | * |
||
555 | * The rest of the options will be rendered as the attributes of the resulting tag. The values will |
||
556 | * be HTML-encoded using [[Html::encode()]]. If a value is `null`, the corresponding attribute will not be rendered. |
||
557 | * |
||
558 | * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
||
559 | * |
||
560 | * @param bool $enclosedByLabel whether to enclose the checkbox within the label. |
||
561 | * If `true`, the method will still use [[template]] to layout the checkbox and the error message |
||
562 | * except that the checkbox is enclosed by the label tag. |
||
563 | * @return $this the field object itself. |
||
564 | */ |
||
565 | public function checkbox($options = [], $enclosedByLabel = true) |
||
586 | |||
587 | /** |
||
588 | * Renders a drop-down list. |
||
589 | * The selection of the drop-down list is taken from the value of the model attribute. |
||
590 | * @param array $items the option data items. The array keys are option values, and the array values |
||
591 | * are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). |
||
592 | * For each sub-array, an option group will be generated whose label is the key associated with the sub-array. |
||
593 | * If you have a list of data models, you may convert them into the format described above using |
||
594 | * [[ArrayHelper::map()]]. |
||
595 | * |
||
596 | * Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in |
||
597 | * the labels will also be HTML-encoded. |
||
598 | * @param array $options the tag options in terms of name-value pairs. |
||
599 | * |
||
600 | * For the list of available options please refer to the `$options` parameter of [[\yii\helpers\Html::activeDropDownList()]]. |
||
601 | * |
||
602 | * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
||
603 | * |
||
604 | * @return $this the field object itself. |
||
605 | */ |
||
606 | public function dropDownList($items, $options = []) |
||
615 | |||
616 | /** |
||
617 | * Renders a list box. |
||
618 | * The selection of the list box is taken from the value of the model attribute. |
||
619 | * @param array $items the option data items. The array keys are option values, and the array values |
||
620 | * are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). |
||
621 | * For each sub-array, an option group will be generated whose label is the key associated with the sub-array. |
||
622 | * If you have a list of data models, you may convert them into the format described above using |
||
623 | * [[\yii\helpers\ArrayHelper::map()]]. |
||
624 | * |
||
625 | * Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in |
||
626 | * the labels will also be HTML-encoded. |
||
627 | * @param array $options the tag options in terms of name-value pairs. |
||
628 | * |
||
629 | * For the list of available options please refer to the `$options` parameter of [[\yii\helpers\Html::activeListBox()]]. |
||
630 | * |
||
631 | * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
||
632 | * |
||
633 | * @return $this the field object itself. |
||
634 | */ |
||
635 | 2 | public function listBox($items, $options = []) |
|
644 | |||
645 | /** |
||
646 | * Renders a list of checkboxes. |
||
647 | * A checkbox list allows multiple selection, like [[listBox()]]. |
||
648 | * As a result, the corresponding submitted value is an array. |
||
649 | * The selection of the checkbox list is taken from the value of the model attribute. |
||
650 | * @param array $items the data item used to generate the checkboxes. |
||
651 | * The array values are the labels, while the array keys are the corresponding checkbox values. |
||
652 | * @param array $options options (name => config) for the checkbox list. |
||
653 | * For the list of available options please refer to the `$options` parameter of [[\yii\helpers\Html::activeCheckboxList()]]. |
||
654 | * @return $this the field object itself. |
||
655 | */ |
||
656 | public function checkboxList($items, $options = []) |
||
665 | |||
666 | /** |
||
667 | * Renders a list of radio buttons. |
||
668 | * A radio button list is like a checkbox list, except that it only allows single selection. |
||
669 | * The selection of the radio buttons is taken from the value of the model attribute. |
||
670 | * @param array $items the data item used to generate the radio buttons. |
||
671 | * The array values are the labels, while the array keys are the corresponding radio values. |
||
672 | * @param array $options options (name => config) for the radio button list. |
||
673 | * For the list of available options please refer to the `$options` parameter of [[\yii\helpers\Html::activeRadioList()]]. |
||
674 | * @return $this the field object itself. |
||
675 | */ |
||
676 | public function radioList($items, $options = []) |
||
685 | |||
686 | /** |
||
687 | * Renders a widget as the input of the field. |
||
688 | * |
||
689 | * Note that the widget must have both `model` and `attribute` properties. They will |
||
690 | * be initialized with [[model]] and [[attribute]] of this field, respectively. |
||
691 | * |
||
692 | * If you want to use a widget that does not have `model` and `attribute` properties, |
||
693 | * please use [[render()]] instead. |
||
694 | * |
||
695 | * For example to use the [[MaskedInput]] widget to get some date input, you can use |
||
696 | * the following code, assuming that `$form` is your [[ActiveForm]] instance: |
||
697 | * |
||
698 | * ```php |
||
699 | * $form->field($model, 'date')->widget(\yii\widgets\MaskedInput::className(), [ |
||
700 | * 'mask' => '99/99/9999', |
||
701 | * ]); |
||
702 | * ``` |
||
703 | * |
||
704 | * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
||
705 | * |
||
706 | * @param string $class the widget class name. |
||
707 | * @param array $config name-value pairs that will be used to initialize the widget. |
||
708 | * @return $this the field object itself. |
||
709 | */ |
||
710 | public function widget($class, $config = []) |
||
724 | |||
725 | /** |
||
726 | * Adjusts the `for` attribute for the label based on the input options. |
||
727 | * @param array $options the input options. |
||
728 | */ |
||
729 | 15 | protected function adjustLabelFor($options) |
|
739 | |||
740 | /** |
||
741 | * Returns the JS options for the field. |
||
742 | * @return array the JS options. |
||
743 | */ |
||
744 | 5 | protected function getClientOptions() |
|
815 | |||
816 | /** |
||
817 | * Checks if client validation enabled for the field |
||
818 | * @return bool |
||
819 | * @since 2.0.11 |
||
820 | */ |
||
821 | 4 | protected function isClientValidationEnabled() |
|
825 | |||
826 | /** |
||
827 | * Checks if ajax validation enabled for the field |
||
828 | * @return bool |
||
829 | * @since 2.0.11 |
||
830 | */ |
||
831 | 4 | protected function isAjaxValidationEnabled() |
|
835 | |||
836 | /** |
||
837 | * Returns the HTML `id` of the input element of this form field. |
||
838 | * @return string the input id. |
||
839 | * @since 2.0.7 |
||
840 | */ |
||
841 | 16 | protected function getInputId() |
|
845 | |||
846 | /** |
||
847 | * Adds aria attributes to the input options |
||
848 | * @param $options array input options |
||
849 | * @since 2.0.11 |
||
850 | */ |
||
851 | 14 | protected function addAriaAttributes(&$options) |
|
864 | } |
||
865 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: