{"id":18654772,"url":"https://github.com/wieni/wmcustom_entity_form","last_synced_at":"2025-11-05T17:30:34.252Z","repository":{"id":57080583,"uuid":"210279186","full_name":"wieni/wmcustom_entity_form","owner":"wieni","description":"An easy way to extend from a Drupal core EntityForm per bundle.","archived":false,"fork":false,"pushed_at":"2023-09-12T12:16:54.000Z","size":9,"stargazers_count":0,"open_issues_count":5,"forks_count":2,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-01-28T01:02:27.373Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wieni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-23T06:21:40.000Z","updated_at":"2023-09-12T12:16:14.000Z","dependencies_parsed_at":"2022-08-24T14:57:37.659Z","dependency_job_id":null,"html_url":"https://github.com/wieni/wmcustom_entity_form","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wieni%2Fwmcustom_entity_form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wieni%2Fwmcustom_entity_form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wieni%2Fwmcustom_entity_form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wieni%2Fwmcustom_entity_form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wieni","download_url":"https://codeload.github.com/wieni/wmcustom_entity_form/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239467450,"owners_count":19643605,"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-11-07T07:16:33.453Z","updated_at":"2025-11-05T17:30:34.220Z","avatar_url":"https://github.com/wieni.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://www.wieni.be\"\u003e\n    \u003cimg src=\"https://www.wieni.be/themes/custom/drupack/logo.svg\" alt=\"Wieni logo\" title=\"Wieni\" align=\"right\" height=\"60\" /\u003e\n\u003c/a\u003e\n\nDrupal Custom Entity Form\n======================\n\n\u003e Use custom entity forms per bundle.\n\n## Installation\n\n```\ncomposer require wieni/wmcustom_entity_form\ndrush en wmcustom_entity_form\n```\n\n## Why\n\nBecause you like to build forms tailored to your client's needs. But you also like to keep codebase clean. \n\n## Use\nThis plugin-based module will look for entity forms in the `Form/Entity` directory of your modules.\n\nThe classes have to implement the `@EntityForm` annotation. The `id` you give that annotation will be\nused to match the entity type and bundle.\n\n## Caveats\n\nThis only works on forms created by the EntityFormBuilder. It won't kick in if your form is shown using\ninline entity form. In that case you'll still need to use `HOOK_inline_entity_form_entity_form_alter` \n\n## Example\n\n```php\n\u003c?php\n\nnamespace Drupal\\mymodule\\Form\\Entity;\n\nuse Drupal\\Core\\Form\\FormStateInterface;\nuse Drupal\\wmcustom_entity_form\\Annotation\\EntityForm;\nuse Drupal\\node\\NodeForm;\nuse Symfony\\Component\\DependencyInjection\\ContainerInterface;\n\n/**\n * @EntityForm(\n *     id=\"node.article\"\n * )\n */\nclass ArticleForm extends NodeForm\n{\n    public static function create(ContainerInterface $container)\n    {\n        // use dependency injection\n        return new static(...);\n    }\n\n    public function form(array $form, FormStateInterface $formState)\n    {\n        $form = parent::form($form, $formState);\n        // alter form without using any hooks\n\n        // use afterbuilds with the :: notation for non-static afterbuilds\n        $form['#after_build'][] = '::myAfterBuild';\n\n        // access $this-\u003eentity; ( powerful combined with wieni/wmmodel )\n        if ($this-\u003eentity-\u003egetWhatever()) {\n            $form['field_foo_bar']['#access'] = false;\n        }\n\n        return $form;\n    }\n\n    public function myAfterBuild(array $form, FormStateInterface $formState)\n    {\n        // access to $this scope and all your injected dependencies\n    }\n\n    // override protected methods of the original entity form\n    protected function actions(array $form, FormStateInterface $formState)\n    {\n        return parent::actions($form, $formState);\n    }\n}\n```\n\n# Also see\n\n- [wieni/wmmodel](https://github.com/wieni/wmmodel) to have a model class per bundle.\n- [wieni/wmcontroller](https://github.com/wieni/wmcontroller) to have a controller per bundle.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwieni%2Fwmcustom_entity_form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwieni%2Fwmcustom_entity_form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwieni%2Fwmcustom_entity_form/lists"}