idct/symfony-form-soft-delete-aware-entity-type-ux-autocomplete
Composer 安装命令:
composer require idct/symfony-form-soft-delete-aware-entity-type-ux-autocomplete
包简介
symfony/ux-autocomplete addon to the SoftDeleteAwareEntityType which adds support for Soft Delete filter behavior to Symfony's EntityType.
README 文档
README
The missing link between softdeleteable from doctrine/extensions, Symfony Form component and
Symfony UX Autocomplete.
Warning!
If you need to use this it most likely means that you have a bad architecture of your software. If you allow deletion or soft deletion you should first make sure
that each related entity is updated first with null or new relation. This form type is meant to be used for transition purposes in systems which need to quickly
add soft deletion on some entities which are used in relations, but due to time or other resources it is impossible to upgrade the actual processes.
Purpose
If you are using the softdeleteable filter and EntityType forms you may encounter a situation when your CRUD Edit form in which the related entity is no longer
available as soft removed. This form type will make the form still properly render, but forcing the user to update the relation using the form.
In such situation, using standard entity type you may see a screen like this:
If you install package idct/symfony-form-soft-delete-aware-entity-type and use the
SoftDeleteAwareEntityType it will revert to the placeholder forcing user to update:
This package, extension, add support for handling the same way soft deleted entities with symfony/ux-autocomplete:
Compatibility
- Symfony 6 or 7.
- Sonata Admin 3+
Installation
First require it in your project:
composer require idct/symfony-form-soft-delete-aware-entity-type-ux-type
NOTE: you need to also configure idct/symfony-form-soft-delete-aware-entity-type.
As this is not a bundle register in your services (for example services.yaml) file:
If you have autowiring:
IDCT\SymfonyFormSoftDeleteAwareEntityType\SoftDeleteAwareEntityType: ~ IDCT\SymfonyFormSoftDeleteAwareEntityType\Ux\BaseSoftDeleteEntityAutocompleteType: ~
If you do not use autowiring you need to pass doctrine as the first argument:
IDCT\SymfonyFormSoftDeleteAwareEntityType\SoftDeleteAwareEntityType: arguments: - '@doctrine' IDCT\SymfonyFormSoftDeleteAwareEntityType\Ux\BaseSoftDeleteEntityAutocompleteType: ~ arguments: - '@doctrine'
Now create your autocomplete Form Type class, same as with UX Autocomplete, but use the parent coming out of this package:
<?php declare(strict_types=1); namespace App\Form; use App\Entity\DeletableEntity; use IDCT\SymfonyFormSoftDeleteAwareEntityType\Ux\BaseSoftDeleteEntityAutocompleteType; use Praetorian\Sportsbook\Orm\Entity\Currency; use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField; #[AsEntityAutocompleteField] class EntityWithDeletableRelationAutocompleteType extends AbstractType { public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'class' => DeletableEntity::class, 'placeholder' => 'placeholder', 'choice_label' => 'name' ]); } public function getParent(): string { return BaseSoftDeleteEntityAutocompleteType::class; } }
And that is all! The rest is normal form usage.
Testing
Tool has a testing toolchain prepared using Docker. If you have docker installed simply run ./run-tests.sh.
This will run unit tests with PHPUnit, generate code-coverage report and run some functional e-2-e tests using Behat and Chrome Driver.
Contribution
Any contribution is more then welcome, please file any issues or pull requests, yet when possible please try to make sure that tests are working.
idct/symfony-form-soft-delete-aware-entity-type-ux-autocomplete 适用场景与选型建议
idct/symfony-form-soft-delete-aware-entity-type-ux-autocomplete 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 112 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 idct/symfony-form-soft-delete-aware-entity-type-ux-autocomplete 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 idct/symfony-form-soft-delete-aware-entity-type-ux-autocomplete 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 112
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-16


