You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently extracted a small bundle from a project I work on and would like feedback on the design.
The idea is to keep using Symfony Forms as the request handling layer, but with a controller argument experience closer to Symfony's request mapping attributes.
Example:
publicfunctioncreate(
#[MapRequestToForm]
Post$post,
): JsonResponse {
// $post is submitted and validated through the resolved form type.
}
It supports:
resolving the form type from data_class
submitting into objects already resolved by Symfony/Doctrine
combining with attributes like MapEntity
returning FormInterface instead of form data when needed
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Symfony community,
I recently extracted a small bundle from a project I work on and would like feedback on the design.
The idea is to keep using Symfony Forms as the request handling layer, but with a controller argument experience closer to Symfony's request mapping attributes.
Example:
It supports:
data_classMapEntityFormInterfaceinstead of form data when neededGitHub: https://github.com/azyouness/request-to-form-bundle
Packagist: https://packagist.org/packages/azyouness/request-to-form-bundle
Update: I wrote a longer article explaining where the idea came from and how the bundle works:
https://dev.to/azyouness/using-symfony-forms-as-controller-arguments-with-maprequesttoform-52ol
I would appreciate feedback on:
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions