atournayre / form
操作表单。
0.0.0
2023-03-11 15:08 UTC
Requires
- php: >=8.0
- ext-ctype: *
- doctrine/dbal: ^3.6
- doctrine/orm: ^2.14
- symfony/form: ^6.2
- symfony/validator: ^6.2
Requires (Dev)
- phpunit/phpunit: ^10.0
Conflicts
- phpstan/phpstan: <0.12.20
- vimeo/psalm: <4.6.1 || 4.6.2
This package is auto-updated.
Last update: 2024-08-31 00:37:15 UTC
README
这个库帮助操作表单。
安装
使用 Composer 安装包
composer require atournayre/form
功能
- 将maxlength属性添加到所有文本字段
示例
namespace App\Subscriber\Form; use Atournayre\Helper\Decorator\Form\MaxLengthFormDecorator; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; class FormDecoratorSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents(): array { return [ FormEvents::PRE_SET_DATA => 'onPreSetData', ]; } public function onPreSetData(FormEvent $event) { $form = $event->getForm(); // Add a maxlength attribute to all text fields. MaxLengthFormDecorator::decorate($form); } }
贡献
欢迎对包的贡献!
许可证
此包的所有内容均受MIT许可证许可。