我在yii2 CRUD生成器中有错误"syntax error, unexpected '}'"
。我在基本/控制器路径中创建了控制器CountryController,在视图中为基本/模型路径和文件夹国家建模了国家。我尝试使用参数进行CRUD操作:
模型类:app \ models \ Country
搜索模型类:app \ models \ CountrySearch
控制器类:app \ controllers \ CountryController
查看路径:@ app / views / country
并且有错误。我无法在谷歌找到解决方案,不知道该怎么做。 错误:
in W:\XAMPP\htdocs\basic\vendor\yiisoft\yii2-gii\generators\crud\default\views\_search.php at line 28
19202122232425262728293031323334353637
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-search">
<?= "<?php " ?>$form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
<?php if ($generator->enablePjax)
?>'options' => [
'data-pjax' => 1
],<?php } >
]); ?>
<?php
$count = 0;
foreach ($generator->getColumnNames() as $attribute) {
if (++$count < 6) {
echo " <?= " . $generator->generateActiveSearchField($attribute) . " ?>\n\n";
} else {
echo " <?php // echo " . $generator->generateActiveSearchField($attribute) . " ?>\n\n";
2. yii\base\ErrorHandler::handleFatalError()
$_GET = [
'r' => 'gii/default/view',
'id' => 'crud',
];
$_POST = [
'_csrf' => 'ZFFUX0VCUjgAMhwAKDgwZ1UQFw8dexZPLwtlZhEMF2AJAh0ZEi8QFQ==',
'Generator' => [
'modelClass' => 'app\\models\\Country',
'searchModelClass' => 'app\\models\\CountrySearch',
'controllerClass' => 'app\\controllers\\CountryController',
'viewPath' => '@app/views/country',
'baseControllerClass' => 'yii\\web\\Controller',
'indexWidgetType' => 'grid',
'enableI18N' => '0',
'enablePjax' => '0',
'messageCategory' => 'app',
'template' => 'default',
],
'preview' => '',
];
$_COOKIE = [
'Phpstorm-b0412478' => '63e8918e-ac29-43de-9816-571b71512aad',
'_csrf' => 'e3a51f05887c990dee11a82408437a3e87c4de7d372dba216a0834374d5b602ca:2:{i:0;s:5:"_csrf";i:1;s:32:"dcH_mzb_1ACPX9DwKZ19TNEXmSIFWmB-";}',
'PHPSESSID' => '2a91078gc1nh6q5br71p0hkuu6',
'_identity' => '8142bf058f7de9bda458b829902ac7db3b69c135c0c908aaaefe8bf2105e8d62a:2:{i:0;s:9:"_identity";i:1;s:28:"["100","test100key",2592000]";}',
];
答案 0 :(得分:0)
如果条件打开,请关闭,尝试低于一个
<?= "<?php " ?>$form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
<?php if ($generator->enablePjax) {
?>'options' => [
'data-pjax' => 1
],<?php } >
]); ?>