← ClaudeAtlas

create-controller-form-actionslisted

Create the form page actions in the admin controller: create (add) and edit, plus any entity-specific actions. Uses FormBuilder/FormHandler pattern — never builds commands directly. Trigger: "create form actions for {Domain}", "create add/edit for {Domain}".
jeffsenso/prestashop-skills · ★ 4 · API & Backend · score 76
Install: claude install-skill jeffsenso/prestashop-skills
# create-controller-form-actions Read `@.ai/Component/Controller/CONTEXT.md` for controller conventions (base class, DI, security attributes, error mapping). Read `@.ai/Component/Forms/CONTEXT.md` for form patterns (FormBuilder, FormHandler, FormDataProvider, FormDataHandler). ## 1. Create action `FormBuilderInterface` and `FormHandlerInterface` are injected as **action arguments** (preferred DI mode — see `Controller/CONTEXT.md`), each with an explicit `#[Autowire(service: '…')]` so the action picks up the domain-specific form services: ```php #[AdminSecurity("is_granted('create', request.get('_legacy_controller'))")] public function createAction( Request $request, #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.{domain}_form_builder')] FormBuilderInterface ${domain}FormBuilder, #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.{domain}_form_handler')] FormHandlerInterface ${domain}FormHandler, ): Response ``` - GET: build form via `FormBuilderInterface::getForm()`, render form template - POST: handle request via `FormHandlerInterface::handle()` — it internally calls `FormDataHandler::create()` which dispatches the Add command - Never instantiate commands directly in the controller - On success: flash message + redirect to index or edit page (return the new entity ID via `getIdentifiableObjectId()`) - On failure: re-render form with errors **Reference:** `TaxController::createAction()`, `ManufacturerControll