zoukankan      html  css  js  c++  java
  • yii2中gii*访问的配置方法

    if (YII_ENV_DEV) {
        // configuration adjustments for 'dev' environment
        $config['bootstrap'][] = 'debug';
        $config['modules']['debug'] = 'yiidebugModule';
    
        $config['bootstrap'][] = 'gii';
        $config['modules']['gii'] = [
            'class' => 'yiigiiModule',
            'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'],
        ];
    }
    

     看来多读英文网站还是很有好处的

    我配置文件写错位置了

    In basic application template configuration structure is a bit different so Gii should be configured in config/web.php:

    basic模版中配置结构有一点不同

    所以应如上写

    那么问题来了,basic例子中这么写是个特例,正常是如何?

    ============

    自定义ActionColumn

    <?= GridView::widget([
            'dataProvider' => $dataProvider,
            //'filterModel' => $searchModel,
            'columns' => [
                ['class' => 'yiigridSerialColumn'],
                //显示的字段
                //code的值
                ['attribute'=>'这是测试code','value'=>function(){return 'abc';}],
                'name',
                'population',
               
                ['class' => 'yiigridActionColumn','header' => '操作',],
                [
                    'label'=>'更多操作',
                    'format'=>'raw',
                    'value' => function($data){
                        $url = "http://www.baidu.com";
                        return Html::a('添加权限组', $url, ['title' => '审核']);
                    }
                ]       
            ],
        ]); ?>

    运行效果如下图所示:

    希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。

    这里有教程http://www.jb51.net/article/58531.htm

    Yii中使用PHPExcel导出Excel的方法

    模板中url

    $url=['books/index'];
    
    //yii2实际生成的网址
    //http://115.29.37.34/advanced/backend/web/index.php?r=books/index

    另外

    $url = 'books/index';
    
    //yii2实际生成的网址
    //http://115.29.37.34/advanced/backend/web/books/index

    所以,在自定义ActionColumn的时候要注意这种写法

    自定义列

    自定义列的写法
    
     22     <?= gridview::widget([
     23         'dataprovider' => $dataprovider,
     24         'filtermodel' => $searchmodel,
     25         'columns' => [
     26             ['class' => 'yiigridserialcolumn'],
     27 
     28             'id',
     29             'exam_name',
     30 
     31             ['class' => 'yiigridactioncolumn','header' => '操作'],
     32             [
     33                 'label' => '更多操作',
     34                 'format' => 'raw',
     35                 'value' => function($data){
     36                 $url=[lbooks/index';
     37                         return html::a('添加科目',$url,
     38                         ['title' => '审核']
     39                         );  
     40                     }
     41             ]   
     42         ],
     43     ]); ?>
  • 相关阅读:
    hdu 2544 Dijstra模板题
    hdu 1002 prime 模板
    POJ_2653_Pick-up sticks_判断线段相交
    POJ_1556_The Doors_判断线段相交+最短路
    POJ_1269_Intersecting Lines_求直线交点
    POJ_3304_Segments_线段判断是否相交
    POJ_2318_TOYS&&POJ_2398_Toy Storage_二分+判断直线和点的位置关系
    ZOJ_2314_Reactor Cooling_有上下界可行流模板
    LuoguP4234_最小差值生成树_LCT
    BZOJ_3996_[TJOI2015]线性代数_最大权闭合子图
  • 原文地址:https://www.cnblogs.com/asworm/p/4504137.html
Copyright © 2011-2022 走看看