doumanju2533 2014-12-30 06:47
浏览 131

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

I know the below code creates bootstrap modal with ADD button. I want to make this work in update button. And below that is the yii2 action column of index page. I need to open bootstrap modal when the update button is clicked.

Modal Code

            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(); 

Action Column in index page

  [
    '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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
    • ¥15 IAR程序莫名变量多重定义
    • ¥15 (标签-UDP|关键词-client)
    • ¥15 关于库卡officelite无法与虚拟机通讯的问题
    • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
    • ¥15 目标检测项目无法读取视频
    • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
    • ¥100 求采集电商背景音乐的方法
    • ¥15 数学建模竞赛求指导帮助
    • ¥15 STM32控制MAX7219问题求解答