douqun1977 2016-10-17 08:03
浏览 35
已采纳

CRUD生成器yii2错误

I have error "syntax error, unexpected '}'" in yii2 CRUD generator. I created controller CountryController in basic/controllers path, model Country in basic/models path and folder country in views. I'm trying to make CRUD operation with parameters:

Model Class : app\models\Country

Search Model Class : app\models\CountrySearch

Controller Class : app\controllers\CountryController

View path : @app/views/country

and have error. I cant find solution in google and dont know what to do. ERROR:

 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) . " ?>

";
    } else {
        echo "    <?php // echo " . $generator->generateActiveSearchField($attribute) . " ?>

";
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]";}',
];
  • 写回答

1条回答 默认 最新

  • douhuocuo9012 2016-10-17 08:09
    关注

    You close if condition ,where it is open,try below one

    <?= "<?php " ?>$form = ActiveForm::begin([
        'action' => ['index'],
        'method' => 'get',
    <?php if ($generator->enablePjax) {
        ?>'options' => [
            'data-pjax'   => 1
        ],<?php } >
    ]); ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示