Download the PHP package solidworx/form-handler-bundle without Composer
On this page you can find all versions of the php package solidworx/form-handler-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download solidworx/form-handler-bundle
More information about solidworx/form-handler-bundle
Files in solidworx/form-handler-bundle
Package form-handler-bundle
Short Description Easy form handling for Symfony forms
License MIT
Informations about the package form-handler-bundle
FormHandlerBundle
The FormHandler component attempts to make controllers with basic form handlers cleaner by off-loading form handling to separate classes.
Table of Contents
- Requirements
- Installation
- Composer
- Usage
- Testing
- Contributing
- Licence
Requirements
FormHandler requires PHP 7.1+ and Symfony 3.0+
Installation
Composer
Then register the bundle in your Symfony application:
Usage
A form can have a class that implements the FormHandlerInterface
interface. This interface exposes a single method in which the form can be retrieved:
This method can either return a standard form type, or use the factory to generate a form type.
The benefit of using the factory, is when you need to pass additional information or options to the form, E.G
To register your form handler, register it as a service:
Inside your controller, use the form.handler
service to handle your form:
This will process the necessary logic on the form (submit the form and handle the request etc).
If you need to handle a failed form, you need to implement the FormHandlerFailInterface
interface:
If you need to handle a successful form submission, implement the FormHandlerSuccessInterface
interface:
Adding options to a form
If you need to pass options to a form, you can add it as an array to the second argument of FormHandler::handle
:
The options will then be available in the getForm
method as a Options
object:
You can also configure the options to set what options is allowed, set default values, define required options etc. by implementing the FormHandlerOptionsResolver
interface:
Advanced Usage
That is the very basics of the component. There are more advanced usages where you can customize the handling of a form to your specific needs.
Testing
To run the unit tests, execute the following command
Contributing
See CONTRIBUTING
License
FormHandler is open-sourced software licensed under the MIT license
Please see the LICENSE file for the full license.
All versions of form-handler-bundle with dependencies
symfony/framework-bundle Version ^4.4 || ^5.0 || ^6.0
symfony/form Version ^4.0 || ^5.0 || ^6.0
symfony/event-dispatcher Version ^4.4 || ^5.0 || ^6.0
symfony/http-foundation Version ^4.4 || ^5.0 || ^6.0
symfony/options-resolver Version ^4.4 || ^5.0 || ^6.0