antonyz89/yii2-mdbootstrap
Composer 安装命令:
composer require antonyz89/yii2-mdbootstrap
包简介
Material Design Bootstrap 5 for Yii2
README 文档
README
Material Design Bootstrap 5 for Yii2
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist antonyz89/yii2-mdb "*"
or add
"antonyz89/yii2-mdb": "*"
to the require section of your composer.json file.
Usage
- add
MDBootstrapPluginAsset::classandMDBootstrapAsset::classto yourAppAsset::class
use antonyz89\mdb\MDBootstrapAsset; use yii\web\YiiAsset; class AppAsset extends AssetBundle { public $basePath = '@webroot'; public $baseUrl = '@web'; public $css = []; public $js = []; public $depends = [ // ... MDBootstrapPluginAsset::class, // 1st MDBootstrapAsset::class, // 2nd ]; }
i18n
add in common\config\main.php
return [ ... 'components' => [ ... 'i18n' => [ 'translations' => [ 'mdb' => [ 'class' => PhpMessageSource::class, 'basePath' => '@antonyz89/mdb/messages', ], ], ], ] ];
Modal
- Close modal after submit
- Callback after submit
⚠️ IMPORTANT:
modal=1is added to URL when submit is triggered on modal to ignore ajax validation requests and save your model successfully.data-callbackattribute is required even you don't wan't use a callback ( in this case usecallback=null,data-callback=falseor something else ). This is because when an<a>tag is clicked withdata-callbackattribute will add andata-ajax=1on your form to do submit via ajax and close modal when you return{ success: true }
<?= Html::a( Html::icon('plus'), ['example/create'], [ 'id' => 'add_example', 'class' => 'btn btn-success show-modal', // .show-modal is required 'data' => [ 'target' => '#modal', 'header' => 'Create Example', 'callback' => 'modalCallback' // (required) your callback function who will be called after submit receiving response from server ] ] ) ?> <?php $js = <<<JS function modalCallback(data) { if (data.success) { // do something } } JS; ?>
public function actionCreate() { $model = new Example(); // check if request is made via modal $isModal = $this->request->get('modal'); if ($model->load(Yii::$app->request->post())) { // (opcional) ajax validation (disabled if modal ins't null) if (Yii::$app->request->isAjax && !$isModal) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } if ($model->save()) { // if request is made via modal then return json object if ($isModal) { $this->response->format = Response::FORMAT_JSON; return [ // returning [[success => true]] closes modal 'success' => true, // your data here 'model' => $model, 'message' => Yii::t('app', 'Created successfully'), ]; } Yii::$app->session->setFlash('success', Yii::t('app', 'Created successfully')); return $this->redirect(['index']); } } return $this->render('create', [ 'model' => $model, ]); }
CREDITS
- UI components built with Material Design Bootstrap 5.
- Kartik enhanced Yii2's components
Support the project
- Star the repo
- Create issue report or feature request
antonyz89/yii2-mdbootstrap 适用场景与选型建议
antonyz89/yii2-mdbootstrap 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 403 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bootstrap」 「extension」 「design」 「yii2」 「material」 「bootstrap5」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 antonyz89/yii2-mdbootstrap 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 antonyz89/yii2-mdbootstrap 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 antonyz89/yii2-mdbootstrap 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
Adds more BBCode
A Laravel package for the Repository Design Pattern.
统计信息
- 总下载量: 403
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-17