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     ]); ?>
  • 相关阅读:
    Lambda表达式、依赖倒置
    ASP.NET vNext 概述
    Uname
    RHEL4 i386下安装rdesktop【原创】
    Taxonomy of class loader problems encountered when using Jakarta Commons Logging(转)
    How to decompile class file in Java and Eclipse
    先有的资源,能看的速度看,不能看的,抽时间看。说不定那天就真的打不开了(转)
    Google App Engine 学习和实践
    【VBA研究】VBA通过HTTP协议实现邮件轨迹跟踪查询
    js正則表達式语法
  • 原文地址:https://www.cnblogs.com/asworm/p/4504137.html
Copyright © 2011-2022 走看看