M
M
Maxim Osadchy2018-05-03 10:41:15
Yii
Maxim Osadchy, 2018-05-03 10:41:15

Why does kartik editable return different post index?

Method in 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 CallsMaindata post array constantly comes under a different index, I have to hack with foreach break (it's good that only one line should come, so I just take the first one).
Has anyone come across what could be the reason?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2018-05-03
@waspmax1

most likely the index contains the line number (or something similar).
You can get rid of the loop by using the reset function, for example:

$callsMaindatum = reset($CallsMaindata);
$model->call_status = $callsMaindatum['call_status'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question