{"id":23219105,"url":"https://github.com/b2pweb/bdf-form-bundle","last_synced_at":"2026-01-26T19:39:09.978Z","repository":{"id":43480969,"uuid":"331335551","full_name":"b2pweb/bdf-form-bundle","owner":"b2pweb","description":"Symfony bundle for BDF Form","archived":false,"fork":false,"pushed_at":"2024-10-15T08:57:55.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-14T09:35:58.712Z","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/b2pweb.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-01-20T14:43:26.000Z","updated_at":"2024-10-15T08:57:59.000Z","dependencies_parsed_at":"2023-02-04T00:16:55.391Z","dependency_job_id":null,"html_url":"https://github.com/b2pweb/bdf-form-bundle","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-form-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-form-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-form-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-form-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b2pweb","download_url":"https://codeload.github.com/b2pweb/bdf-form-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230340212,"owners_count":18211180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-12-18T21:19:18.678Z","updated_at":"2026-01-26T19:39:04.910Z","avatar_url":"https://github.com/b2pweb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BDF Form Bundle\n\nBundle for [BDF Form](https://github.com/b2pweb/bdf-form)\n\n[![build](https://github.com/b2pweb/bdf-form-bundle/actions/workflows/php.yml/badge.svg)](https://github.com/b2pweb/bdf-form-bundle/actions/workflows/php.yml)\n[![Packagist Version](https://img.shields.io/packagist/v/b2pweb/bdf-form-bundle.svg)](https://packagist.org/packages/b2pweb/bdf-form-bundle)\n[![Total Downloads](https://img.shields.io/packagist/dt/b2pweb/bdf-form-bundle.svg)](https://packagist.org/packages/b2pweb/bdf-form-bundle)\n\n## Installation\n\n```\ncomposer require b2pweb/bdf-form-bundle\n```\n\nAnd then add to `config/bundles.php` :\n\n```php\n\u003c?php\n\nreturn [\n    // ...\n    Bdf\\Form\\Bundle\\FormBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\n## Configuration\n\nTo enable auto registration of custom forms and builders, simply enable `autoconfigure` and load the package sources :\n\n```yaml\nservices:\n    _defaults:\n        autowire: true\n        autoconfigure: true\n\n    App\\Form\\:\n        resource: './src/Form/*'\n```\n\nTo use CSRF, do not forget to enable the CSRF service :\n\n```yaml\nframework:\n    csrf_protection:\n        enabled: true\n```\n\n## Usage\n\nSimply use the container to instantiate the custom form.\n\n\u003e Note: The container will automatically inject all dependencies\n\n```php\n// Declare the form\nclass MyForm extends \\Bdf\\Form\\Custom\\CustomForm\n{\n    /**\n     * @var MyService \n     */\n    private $service;\n    \n    // You can declare dependencies on the constructor \n    public function __construct(MyService $service, ?\\Bdf\\Form\\Aggregate\\FormBuilderInterface $builder = null) \n    {\n        parent::__construct($builder);\n        \n        $this-\u003eservice = $service;\n    }\n\n    protected function configure(\\Bdf\\Form\\Aggregate\\FormBuilderInterface $builder) : void\n    {\n        // Configure fields\n    }\n}\n\n// The controller\nclass MyController extends AbstractController\n{\n    public function save(Request $request)\n    {\n        // Create the form using the container\n        $form = $this-\u003econtainer-\u003eget(MyForm::class);\n        \n        // Submit data\n        if (!$form-\u003esubmit($request-\u003erequest-\u003eall())-\u003evalid()) {\n            throw new FormError($form-\u003eerror());\n        }\n        \n        $this-\u003eservice-\u003esave($form-\u003evalue());\n        \n        return new Reponse('ok');\n    }\n}\n```\n\n## With PHP 8 attributes\n\nThis bundle supports [BDF Form attribute](https://github.com/b2pweb/bdf-form-attribute).\n\nInstall the library using composer :\n\n```\ncomposer require b2pweb/bdf-form-attribute\n```\n\nAdd configuration into `config/packages/form.yaml`\n\n```yaml\nform:\n  attributes:\n    compile: true # enable compilation of attributes to native PHP code\n    configuratorClassPrefix: 'GeneratedForm\\' # Define base namespace (or class prefix) for generated classes\n    configuratorClassSuffix: 'Configurator' # Define generated classes suffix\n    configuratorBasePath: '%kernel.build_dir%/form' # Define the save path\n```\n\nTo disable code generation during development, set configuration `config/packages/dev/form.yaml` :\n\n```yaml\nform:\n  attributes:\n    compile: false # disable compilation to build dynamically forms\n```\n\nOnce configured, you can simply declare forms like [example](https://github.com/b2pweb/bdf-form-attribute#declare-a-form-class).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb2pweb%2Fbdf-form-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb2pweb%2Fbdf-form-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb2pweb%2Fbdf-form-bundle/lists"}