insitaction/easyadmin-fields-bundle
Composer 安装命令:
composer require insitaction/easyadmin-fields-bundle
包简介
Set of easyadmin fields and useful helpers for Insitaction
README 文档
README
I don't have time for this and I don't work on EasyAdmin backoffice anymore I strongly encourage anyone who can to make a better bundle for this, many bugs were encountered, the main paint points are to find a correct selector that won't have any side effects, and make everything compatible with the lifecycle of the forms
EasyAdminFieldsBundle
Installation
Run the following command to install EasyAdminFields in your application:
$ composer require insitaction/easyadmin-fields-bundle
Use the bundle assets
// DashboardController.php use Insitaction\EasyAdminFieldsBundle\EasyAdminFieldsBundle; public function configureAssets(): Assets { $assets = parent::configureAssets(); return EasyAdminFieldsBundle::configureAssets($assets); }
Without the helper method
// DashboardController.php use Insitaction\EasyAdminFieldsBundle\Asset\AssetPackage; public function configureAssets(): Assets { $jsAsset = Asset::new('app.js')->package(AssetPackage::PACKAGE_NAME); $cssAsset = Asset::new('app.css')->package(AssetPackage::PACKAGE_NAME); return parent::configureAssets() ->addJsFile($jsAsset) ->addCssFile($cssAsset); }
Fields
Mask field
The mask field allows you to show or hide other fields depending on one field's value
Usage
- With the MaskField wrapper
MaskField::adapt( BooleanField::new('hasAuthor'), [ "true" => ['author'] ] )
- Directly adding form type options to your field
BooleanField::new('hasAuthor') ->setFormTypeOptions([ 'row_attr' => [ 'data-controller' => 'mask-field', 'data-mask-field-map' => MaskField::encodeMap([ "true" => ['author'] ]) ], ])
Configuration
The map configuration works like this:
- The key corresponds to an input value
- The value is an array of field names
With this map configuration :
[
"true" => ['author']
]
The author field is shown only when true is the input value, otherwise, the author field is masked
With this map configuration :
[
"A" => ['field1'],
"B" => ['field1', 'field2'],
"C" => ['field2'],
]
The field1 field is shown when either A or B is the input value, the field2 field is shown when either B
or C is the input value
Dependent field
The dependent field can wrap ChoiceField or AssociationField to make their available options dynamic If any of the field dependencies is updated, a request is emitted to retrieve new options for the dependent field
Usage
- With the DependentField wrapper
DependentField::adapt( AssociationField::new('author'), [ 'callback_url' => $this->urlGenerator->generate('authors', [], UrlGeneratorInterface::ABSOLUTE_URL), 'dependencies' => ['gender'], 'fetch_on_init' => true ] )
Configuration
Dependencies
The dependencies array is an array of string corresponding to other fields name
With this dependencies configuration, the callback will be called everytime the gender field is updated
'dependencies' => ['gender']
Callback Url
The callback_url must be an url that accepts a GET request which returns data of this format:
[
{
"text": "John Doe",
"value": 1
},
{
"text": "John Snow",
"value": 2
}
]
The following query parameters will be sent with the request (this corresponds to the dependencies array and the corresponding field value)
{
"gender": "Male"
}
Fetch on init
The fetch_on_init parameter defines wheter or not the callback should be executed immediatly after the field is
mounted
insitaction/easyadmin-fields-bundle 适用场景与选型建议
insitaction/easyadmin-fields-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.55k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2021 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 insitaction/easyadmin-fields-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 insitaction/easyadmin-fields-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 11.55k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-06