如何在YII2中添加bootstrap模式来更新动作

时间:2014-12-30 06:47:56

标签: php twitter-bootstrap-3 yii2 bootstrap-modal

我知道下面的代码使用ADD按钮创建bootstrap模式。我想在更新按钮中完成这项工作。下面是索引页面的yii2操作列。 单击更新按钮时,我需要打开bootstrap模式。

模态代码

            Modal::begin([
            'toggleButton' => [
                'label' => '<i class="glyphicon glyphicon-plus"></i> Add',
                'class' => 'btn btn-success'
            ],
                'closeButton' => [
                'label' => 'Close',
                'class' => 'btn btn-danger btn-sm pull-right',
            ],
                'size' => 'modal-lg',
            ]);
                $newmodel = new Comment();

                echo $this->render('/comment/create', ['model' => $newmodel]);

            Modal::end(); 

索引页面中的操作列

  [
    'class' => 'yii\grid\ActionColumn',
    'template' => '{view}&nbsp;&nbsp;&nbsp;{update} &nbsp;&nbsp;&nbsp;{delete}',
    /* 'buttons'=>[
        'view' => function ($url, $comment) {     
           return Html::a('<span class="glyphicon glyphicon-plus">
                     </span>',$url,           
            [
                'title' => Yii::t('yii', 'view'),
             ]);
         }
        ], */
      'urlCreator' => function ($action, $dataProvider, $key, $index) {
        if ($action === 'view') {
            $url = Yii::$app->urlManager->createUrl('option?id='.$key.''); 
            return $url;
        }
        if ($action === 'update') {
        $url = Yii::$app->urlManager->createUrl('question/update?id='.$key.''); 
            return $url;
        }
        if ($action === 'delete') {
        $url = Yii::$app->urlManager->createUrl('question/delete?id='.$key.''); 
            return $url;
         }
      }
 ],

[ 'class' => 'yii\grid\ActionColumn', 'template' => '{view}&nbsp;&nbsp;&nbsp;{update} &nbsp;&nbsp;&nbsp;{delete}', /* 'buttons'=>[ 'view' => function ($url, $comment) { return Html::a('<span class="glyphicon glyphicon-plus"> </span>',$url, [ 'title' => Yii::t('yii', 'view'), ]); } ], */ 'urlCreator' => function ($action, $dataProvider, $key, $index) { if ($action === 'view') { $url = Yii::$app->urlManager->createUrl('option?id='.$key.''); return $url; } if ($action === 'update') { $url = Yii::$app->urlManager->createUrl('question/update?id='.$key.''); return $url; } if ($action === 'delete') { $url = Yii::$app->urlManager->createUrl('question/delete?id='.$key.''); return $url; } } ],

0 个答案:

没有答案