Why kartik editable returns a different index in the post?

0 like 0 dislike
6 views
The method in the controller:
$CallsMaindata = Yii::$app->request->post('CallsMaindata'); $id = Yii::$app->request->post('editableKey'); $model = CallsMaindata::find()->where(['id' => $id])->one(); if(is_array($CallsMaindata)){ foreach ($CallsMaindata as $callsMaindatum) { $model->call_status = $callsMaindatum['call_status']; break; } }

Due to the fact that call_status in the array of post CallsMaindata comes constantly under different index, we have hostility foreach with a break(well, that should come only one line, so take just the first).
Someone faced, what could be the reason?
Thank you.
by | 6 views

1 Answer

0 like 0 dislike
most likely the index contains the row number (or something similar).
Get rid of the cycle using the reset function, for example:
$callsMaindatum = reset($CallsMaindata); $model->call_status = $callsMaindatum['call_status'];
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,703 users