hostnet / form-handler-bundle
Hostnet form handler to provide an easier way of handling forms in actions
Installs: 143 325
Dependents: 1
Suggesters: 0
Security: 0
Stars: 71
Watchers: 17
Forks: 15
Open Issues: 3
Type:symfony-bundle
Requires
- php: ^8.1
- hostnet/form-handler-component: ^1.7.3
- symfony/expression-language: ^6.4|^7.0
- symfony/http-foundation: ^6.4|^7.0
Requires (Dev)
- hostnet/phpcs-tool: ^9.1.0
- phpunit/phpunit: ^9.5.5
- symfony/browser-kit: ^6.4|^7.0
- symfony/finder: ^6.4|^7.0
- symfony/form: ^6.4|^7.0
- symfony/framework-bundle: ^6.4|^7.0
- symfony/http-kernel: ^6.4|^7.0
- symfony/phpunit-bridge: ^6.4|^7.0
- symfony/translation: ^6.4|^7.0
- symfony/validator: ^6.4|^7.0
- symfony/yaml: ^6.4|^7.0
This package is auto-updated.
Last update: 2024-12-13 09:56:40 UTC
README
The form handlers are designed to enhance the developer experience (DX) when working with Symfony forms. It makes the controllers simpler by moving the form success and failure flows to a separate class.
class YourController extends Controller { public function formAction(Request $request, MyEntityUser $user) { $handler = $this->get('hostnet.form_handler.factory')->create(MyFormHandler::class); if (($response = $handler->handle($request, new MyFormData())) instanceof RedirectResponse) { return $response; } // regular or in-valid flow return $this->render->renderView('/your/form.html.twig', [ 'form' => $handler->getForm()->createView() ]); } }
By extracting the success - and if available, the failure - flows, you reduce the amount of code in your controllers, which in turn, achieves slim controllers. The definition of a controller is according to Symfony: "a PHP function you create that reads information from the Symfony's Request object and creates and returns a Response object".
Installation
- Read the installation guide when using composer.
- This bundle and the component follow semantic versioning strictly.
Documentation
- Read the Getting Started guide if you are new to form handlers.
- You can find the full documentation on our github wiki pages.
- If you are migrating from 1.1 to 1.2 or 2.x, check the migration guide.
- The legacy documentation for 1.1 is still available but upgrading is recommended.
License
The hostnet/form-handler-bundle
is licensed under the MIT License, meaning you can reuse the code within proprietary software provided that all copies of the licensed software include a copy of the MIT License terms and the copyright notice.
Get in touch
- We are available on the symfony-devs slack server in #hostnet-form-handlers.
- Or via our email: opensource@hostnet.nl.