[英]Yii2 error:Maximum function nesting level of '100' reached, aborting
In _form.php I am trying to use this simple code and I am getting the error: 在_form.php中我试图使用这个简单的代码,我收到错误:
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use app\models\State;
/* @var $this yii\web\View */
/* @var $model app\models\State */
/* @var $form yii\widgets\ActiveForm */
$model = new State();
?>
<?= $this->render('_form', [
'model' => $model,
]) ?>
Why I am getting this error. 为什么我收到此错误。 As the same code was working fine. 因为相同的代码工作正常。
If that is indeed code from "_form.php", then the following code is recursively rendering _form.php inside itself: 如果那确实是来自“_form.php”的代码,那么下面的代码将递归地呈现_form.php:
<?= $this->render('_form', [
'model' => $model,
]) ?>
Joshi is correct, and the reason it's happening is because that you're calling render() instead of renderPartial(). Joshi是正确的,它发生的原因是因为你正在调用render()而不是renderPartial()。 Change your code to this, and the error will disappear and your partial will show as expected: 将您的代码更改为此,错误将消失,您的部分将按预期显示:
<?= $this->renderPartial('_form', [
'model' => $model,
]) ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.