{"id":16864457,"url":"https://github.com/ph-fritsche/symfony-form","last_synced_at":"2026-05-18T18:35:14.984Z","repository":{"id":37744653,"uuid":"368781424","full_name":"ph-fritsche/symfony-form","owner":"ph-fritsche","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-22T09:38:00.000Z","size":81,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-26T09:58:16.463Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ph-fritsche.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-19T07:30:06.000Z","updated_at":"2023-03-09T00:44:20.000Z","dependencies_parsed_at":"2022-08-24T16:10:13.007Z","dependency_job_id":null,"html_url":"https://github.com/ph-fritsche/symfony-form","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ph-fritsche/symfony-form","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph-fritsche%2Fsymfony-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph-fritsche%2Fsymfony-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph-fritsche%2Fsymfony-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph-fritsche%2Fsymfony-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ph-fritsche","download_url":"https://codeload.github.com/ph-fritsche/symfony-form/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph-fritsche%2Fsymfony-form/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33187251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T14:42:28.378Z","updated_at":"2026-05-18T18:35:14.968Z","avatar_url":"https://github.com/ph-fritsche.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Form controllers\n\nStreamlined controllers handling form input.\n\n## Usage\n\n### Annotate controller\n\nKeep creating and handling the form input out of your controller by annotating it with the desired [FormType](https://symfony.com/doc/current/forms.html#creating-form-classes).\n\n```php\nnamespace App\\Controller;\n\nuse App\\Form\\MyFormType;\nuse Pitch\\Form\\Form;\n\nclass MyController\n{\n    #[Form(MyFormType::class)]\n    public function __invoke($data)\n    {\n        // Just handle the data of a valid form.\n        // If the form is not submitted yet or the input is invalid,\n        // the controller will not be called and the\n        // Symfony\\Component\\Form\\FormInstance will be returned.\n    }\n}\n```\n\nThis also supports [Doctrine Annotations](https://github.com/doctrine/annotations/) if installed.\n\n### Handle `FormInstance` controller return\n\nSymfony requires controllers to return a `Symfony\\Component\\HttpFoundation\\Response`.\nBut you can convert other return values (like the `FormInstance`) on the `kernel.view` event.\nAdd your own [EventSubscriber](https://symfony.com/doc/current/event_dispatcher.html#creating-an-event-subscriber)\nor [add a ResponseHandler with pitch/symfony-adr](https://github.com/ph-fritsche/symfony-adr#turn-controller-into-action).\n\n### Use the form inside the controller\n\nJust like the data for valid forms the `FormInstance` is made available to the controller per [Request attributes])https://symfony.com/doc/current/components/http_foundation.html#accessing-request-data).\n[Symfony's RequestAttributeValueResolver](https://symfony.com/doc/current/controller/argument_value_resolver.html#built-in-value-resolvers) injects them into the controller if there is a parameter with the same name as the attribute.\nThe attribute names default to just `data` and `form`, but in case of conflicts you could provide others per annotation.\n\n```php\nnamespace App\\Controller;\n\nuse App\\Form\\MyFormType;\nuse Pitch\\Form\\Form;\nuse Symfony\\Component\\Form\\FormInterface;\n\nclass MyController\n{\n    #[Form(\n        MyFormType::class,\n        dataAttr: 'myData',\n        formAttr: 'myForm',\n    )]\n    public function __invoke(\n        Request $request,\n        FormInterface $myForm,\n        $myData,\n    ) {\n    }\n}\n```\n\nYou can prevent the automatic return of invalid or unsubmitted forms per annotation `#[Form(MyFormType::class, returnForm: false)]` or per [config parameter](https://symfony.com/doc/current/configuration.html#configuration-parameters) `pitch_form.returnForm: false`.\n\n### Use data entities\n\n```php\nnamespace App\\Controller;\n\nuse App\\Form\\MyFormType;\nuse App\\Form\\MyFormEntity;\nuse Pitch\\Form\\Form;\n\nclass MyController\n{\n    #[Form(\n        MyFormType::class,\n        entity: MyFormEntity::class,\n    )]\n    public function __invoke(MyFormEntity $data)\n    {\n    }\n}\n```\n\nIf the entity can not be created by just calling the constructor, you can register a factory implementing `Pitch\\Form\\FormEntityFactoryInterface` as a service.\n\n```php\nnamespace App\\Controller;\n\nuse App\\Form\\MyFormType;\nuse App\\Form\\MyFormEntity;\nuse Pitch\\Form\\Form;\n\nclass MyController\n{\n    #[Form(\n        MyFormType::class,\n        entityFactory: 'myFactoryId',\n    )]\n    public function __invoke(MyFormEntity $data)\n    {\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fph-fritsche%2Fsymfony-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fph-fritsche%2Fsymfony-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fph-fritsche%2Fsymfony-form/lists"}