signawebsolutions/yii2-modal-login 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

signawebsolutions/yii2-modal-login

Composer 安装命令:

composer require signawebsolutions/yii2-modal-login

包简介

Make a button that open a Bootstrap4 Modal with the login form

README 文档

README

Make a button that open a Bootstrap4 Modal with the login form

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist signawebsolutions/yii2-modal-login "*"

or add

"signawebsolutions/yii2-modal-login": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

<?= \signa\modallogin\ModalLogin::widget([
    'label' => Yii::t('app', 'Login'),
    'url' => ['/user/login'],
    'loginFormId' => 'login-form',
    'options' => [
        'class' => 'btn',
    ],
    'events' => [
        'onLoginSuccess' => 'function (e) {
            console.log(e.detail);
        }',
    ],
]) ?>

In your user controller, here is an example on how to use the actionLogin method:

    public function actionLogin()
    {
        if (!Yii::$app->user->isGuest) {
            return $this->goHome();
        }

        $model = new LoginForm();

        if ($model->load(Yii::$app->request->post()) && $model->login()) {
            Yii::$app->response->format = 'json';
            return [
            	'success' => true,
            	// pass other data here that you can retrieve in the onLoginSuccess
            ];
        } else {
            if ($model->errors) {
                Yii::$app->response->format = 'json';
                return $model->errors;
            }
            $model->password = '';

            if (Yii::$app->request->isAjax) {
                return $this->renderAjax('login', [
                    'model' => $model,
                ]);
            }
            return $this->render('login', [
                'model' => $model,
            ]);
        }
    }

You can customize this action to fit your project.

If you don't see errors on the modal window, think to add the error summary function inside your form:

<?= $form->errorSummary($model) ?>

统计信息

  • 总下载量: 72
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2020-04-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固