Call to a member function formName() on null

I can’t find any supporting resources for the error Call to a member function formName() on null . The scenario of getting this error when opening a update page. I’ve checked the rendered variable on update page by print_r() and its fine. Then I checked by removing the all input field which codes in yii2 ActiveFrom chtml like

<?= $form->field($model, 'name')->textInput(['maxlength' => true, 'class' => ' form-control']) ?> 

and kept some input fields which is in normal html syntax like

<input type="text" class="qty" name="qty[]" value="1" style="width: 24px;" value="<?php echo $value->qty; ?>">

Then it worked. Why this error occurred and how to fix it. Thanks,

Are you sure that $model is not null? In your raw-HTML solution you’re using $value instead of $model.

I’m sure the $model is not null and it return array when print_r($model) on my update.php

Did you read this?