Download the PHP package kunicmarko/form-annotation-bundle without Composer
On this page you can find all versions of the php package kunicmarko/form-annotation-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kunicmarko/form-annotation-bundle
More information about kunicmarko/form-annotation-bundle
Files in kunicmarko/form-annotation-bundle
Package form-annotation-bundle
Short Description This is a Symfony Bundle that adds helper annotations for symfony forms.
License MIT
Homepage https://github.com/kunicmarko20/FormAnnotationBundle
Informations about the package form-annotation-bundle
Form Annotation Bundle
Adds Form Annotations that helps you avoid boilerplate code when using forms.
Documentation
- Installation
- How to use
- Annotations
Installation
1. Add dependency with composer
2. Register the bundle in your Kernel
How to use
First select the annotation you want to use and add it to your controller action, you have to provide form class and parameter name, also parameter has to have a type.
While FOSRestBundle is not dependency, my examples are with FOSRestBundle and this is mainly used with it.
Before:
After:
The Request enters controller action only if everything in form is valid, else it will return validation errors.
Annotations
There are 3 options you can set when adding annotation to your action:
formType
- FQCN of your form type.parameter
- parameter name you will be using in your action. (parameter has to have a type)clearMissing
- if some value is not sent this will by default set it to null forPOST
/PUT
but forPATCH
this value will be ignored. You can control this on your own if you want.
Post
In POST
we take your parameter and from type you provided. We create
new Object and populate data from Request and if everything is valid we
populate the parameter in your action and we let Request enter your action
else we return form errors.
Patch/Put
Here we depend on Symfony ParamConverter and we expect that the parameter you
provided is already a populated object. If you add {id}
parameter
to your route and type-hint it with Doctrine Entity, Symfony ParamConverter
will already do that. If everything is valid we let Request enter your action
else we return form errors.
All versions of form-annotation-bundle with dependencies
symfony/http-kernel Version ^3.3 || ^4.0
symfony/dependency-injection Version ^3.3 || ^4.0
symfony/event-dispatcher Version ^3.3 || ^4.0
symfony/form Version ^3.3 || ^4.0
symfony/http-foundation Version ^3.3 || ^4.0
doctrine/annotations Version ^1.6
sensio/framework-extra-bundle Version ^3.0 || ^4.0 || ^5.0