A
A
Alexey Gus2021-05-26 21:22:29
PHP
Alexey Gus, 2021-05-26 21:22:29

Why is there an error when accessing the 'id' key in a php array?

the essence of the problem is that an array of parameters is passed to the widget,
in the form

'paramsArr' => ["data-range"=>"true" ,
'data-multiple-dates-separator'=>" - ",
'data-min-view'=>"months",
'data-view'=>"months",
'id' => 'datepicker-summary',
"data-date-format"=>"MM yyyy"],


at the entrance to the widget view, everything comes in and merges with other params, and at the output we get ...
Array
(
    [placeholder] => Начало работы
    [class] => datepicker-here
    [data-position] => right bottom
    [data-range] => true
    [data-multiple-dates-separator] =>  - 
    [data-min-view] => months
    [data-view] => months
    [id] => datepicker-summary
    [data-date-format] => MM yyyy
)


but when trying to access by key 'id '
in the form print_r($params['id']);
we get the error
Undefined index: id

but if after print_r($params['id']) we write exit();
everything is displayed

and the most interesting thing in the view is that we pass this array to the field in the form and it takes this id from it ...
echo $form->field($model, $field)->textInput($params)->label($label);


so the question is why??? what's wrong??? help)) brain broke already))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question