atournayre / form
Manipulate 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-10-31 00:23:37 UTC
README
This library helps manipulating forms.
Installation
Use Composer to install the package:
composer require atournayre/form
Features
- Add a maxlength attribute to all text fields
Example
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); } }
Contribute
Contributions to the package are always welcome!
- Report any bugs or issues you find on the issue tracker.
- You can grab the source code at the package's Git repository.
License
All contents of this package are licensed under the MIT license.