zacksleo/yii2-lookup
Composer 安装命令:
composer require zacksleo/yii2-lookup
包简介
Yii2 lookup module
README 文档
README
Migrate database
To add a lookup table to your database, following is the sql for lookup:
CREATE TABLE IF NOT EXISTS `lookup` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(100) DEFAULT NULL,
`name` varchar(100) DEFAULT NULL,
`code` int(11) DEFAULT '1',
`comment` text,
`active` tinyint(1) DEFAULT '1',
`order` int(11) DEFAULT '1',
`created_at` int(11) DEFAULT NULL,
`updated_at` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `CK_Type_Name_Unique` (`type`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Or else you can use yii migration
yii migrate/up --migrationPath=@zacksleo/yii2/lookup/migrations
Config the components
To access the lookup functionality anywhere in you application (either frontend or backend) follow the following steps:
In your main.php under config folder add the following:
'components' => [
---
'lookup' => [
'class' => 'zacksleo\yii2\lookup\models\Lookup',
],
---
]
Customize the form
Following are the few usage of lookup functionality:
/*** dropdown list from lookup ***/
<?= $form->field($model, 'active')->dropDownList(
Yii::$app->lookup->items('yes_no'),
//['1'=>'Active', '2' => 'Pending'],
['prompt'=>'--- Select ---']
) ?>
/*** RadioButton List ***/
<?= $form->field($model, 'gender')->radioList(
Yii::$app->lookup->items('male_female'), ['separator' => '']
) ?>
/*** CheckBoxes List ***/
<?= $form->field($model, 'language')->checkboxList(
Yii::$app->lookup->items('language'), ['separator' => '']
) ?>
/*** Dropdown List from Lookup ***/
<?= $form->field($model, 'language')->dropDownList(
Yii::$app->lookup->items('language'), ['prompt' => '--- Select ---']
) ?>
Inspired By Ibrar Turi @ibrarturi, Thanks for his work.
zacksleo/yii2-lookup 适用场景与选型建议
zacksleo/yii2-lookup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.18k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2016 年 11 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「module」 「yii2」 「lookup」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zacksleo/yii2-lookup 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zacksleo/yii2-lookup 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zacksleo/yii2-lookup 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
GeoMate is a friend in need for all things geolocation. IP to geo lookup, automatic redirects (based on country, continent, language, etc), site switcher... You name it.
A custom URL rule class for Yii 2 which allows to create translated URL rules
PHP WHOIS provides parsed and raw whois lookup of domains and ASN routes. PHP 7.2+ compatible
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
Get Address IO wrapper covering all endpoints available from the API.
SCEditor, a lightweight WYSIWYG BBCode & HTML editor extension for Yii 2.0 Framework
统计信息
- 总下载量: 11.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2016-11-30