0

When running the code:

return $this->render('update', [
   'model' => $model,
   'stok' => $stok
   ]);

I get an error related to undefined variable:

PHP Notice 'yii\base\ErrorException' with message 'Undefined variable: stok'

My form is as follows:

<div class="col-sm-2">
   <?= $form->field($stok, 'harga_jual1')->textInput(['id' => 'hargaRetail'])->label('Harga Retail') ?>
</div>

How can I resolve this error?

1
  • 1
    you missed update.php from where _form.php rendered. add 'stok' => $stok there also. Commented Jan 10, 2018 at 6:21

2 Answers 2

3

check it out and follow the render what would be do! controller -> render update.php -> _form.php

readd below in _form.php

return $this->render('_form', [
   'model' => $model,
   'stok' => $stok
]);
Sign up to request clarification or add additional context in comments.

Comments

0

You need to check on the update.php, is it already set this block

return $this->render('_form', [
   'model' => $model,
   'stok' => $stok
]);

Usually from actionUpdate controller it's will be render update.php then inside it will be render _form.php, so the $stok variable must be set too in the update.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.