zoukankan      html  css  js  c++  java
  • Yii2 的问题解决方案

    yii2 Class 'appcontrollersAccessControl' not found

    一般是命名空间问题, 写成yiifiltersAccessControl::className(),

    yii2想要新增第三方vendor, 修改composer.json, 

    "require-dev": {
            "yiisoft/yii2-codeception": "*",
            "yiisoft/yii2-debug": "*",
            "yiisoft/yii2-gii": "*",
            "zircote/swagger-php": "*",
            "yiisoft/yii2-faker": "*"
        },
    

     加入了"zircote/swagger-php": "*", 然后运行php composer.phar update发现报错

    于是找到解决方案

    php composer.phar global require "fxp/composer-asset-plugin:~1.1.1"

    然后在php composer.phar update, 不再报错

    表单提交改成Ajax形式验证

    Controller

     if (Yii::$app->request->isAjax) {
                Yii::$app->response->format = yiiwebResponse::FORMAT_JSON;
                return yiiootstrapActiveForm::validate($model);
    }
    

    View

    $form = ActiveForm::begin([
            'enableAjaxValidation' => true, 
        ]);
    

      

    Activeform 下拉菜单多选

    dropdownList(User::getArrayNoticeTargets(), ['multiple' => 'true', 'size' => 3])

    Activeform 生成form是label和input平行样式

    use yiiwidgetsActiveForm;
    $form = ActiveForm::begin([
    'options' => ['class' => 'form-horizontal'],
                    'fieldConfig' => [
                        'template' => "{label}{input}
    {error}",
                        'labelOptions' => ['class' => 'col-md-4'],
                        'inputOptions' => ['class' => 'col-md-6'],
                    ],
    ])
    
    或
    use yiiootstrapActiveForm;
    $form = ActiveForm::begin([
    'layout' => 'horizontal',
    'fieldConfig' => [ 'template' => "{label}
    {beginWrapper}
    {input}
    {hint}
    {error}
    {endWrapper}", 'horizontalCssClasses' => [ 'label' => 'col-sm-4', 'offset' => 'col-sm-offset-4', 'wrapper' => 'col-sm-8', 'error' => '', 'hint' => '', ], ] ])
  • 相关阅读:
    几种滑动验证码处理
    面试题 四 redis线上为什么不能使用 keys *命令
    面试题 六 squid 的理解
    从XP到WIN10,各个系统版本自带 .NET版本整理
    SQL压缩日志
    sql server 使用链接服务器远程查询
    FastReport几个问题
    .Net 三款工作流引擎比较:WWF、netBPM 和 ccflow
    ClientDataSet控件ApplyUpdates的异常触发
    Delphi中关于字符串截取详解
  • 原文地址:https://www.cnblogs.com/derrck/p/5209947.html
Copyright © 2011-2022 走看看