Download the PHP package mitom/form-handler-bundle without Composer
On this page you can find all versions of the php package mitom/form-handler-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mitom/form-handler-bundle
More information about mitom/form-handler-bundle
Files in mitom/form-handler-bundle
Package form-handler-bundle
Short Description Form handler bundle for symfony.
License GPL GNU v2
Informations about the package form-handler-bundle
form-handler-bundle
The aim of this bundle is to simplify the management and submission of forms and provide a level of abstraction over their submission. You will possibly gain the following advantages by using it:
- Fewer dependencies in Controllers
- Easily testable form handling
- Extracting business logic from Controllers
- More re-usable code
It is in an early stage and changes may occur, however the interfaces are unlikely to change. It is recommended that you follow versions, instead of branches (as in ~0.1
).
Installation
Add it in your composer.json
:
Then add the bundle in your AppKernel.php
:
Usage
First of you will need a FormType
to work with, you can create one according to the official symfony documentation. For example:
Next you will have to create your FormHandler
for it. An AbstractFormHandler
is provided in the bundle to make it easier for you, but of course you don't have to use it. The FormHandler
only has to implement the FormHandlerInterface
.
The next step is to register the FormHandler
as a service and tagging it with mitom.form_handler
:
In your controller inject the mitom_form_handler.manager
service:
Alternatively you could inject a FormHandler straight away, if you only need a single handler in your controller. However I'd recommend going through the Manager anyway, as it makes it easy to user other handlers later and keeps thigs consistent.
And finally make use of it:
The example above is using the
Template
annotation to make it shorter, it is however not a dependency of this bundle.