create-twig-form-templatelisted
Install: claude install-skill jeffsenso/prestashop-skills
# create-twig-form-template
Read `@.ai/Component/Twig/CONTEXT.md` for template conventions (layout, flash messages, routes, form themes).
## 1. Form template
Create `src/PrestaShopBundle/Resources/views/Admin/{Section}/{Domain}/form.html.twig`:
```twig
{% extends '@PrestaShop/Admin/layout.html.twig' %}
{% block content %}
{{ form_start(form) }}
{{ form_widget(form) }}
<button type="submit" class="btn btn-primary">
{{ 'Save'|trans({}, 'Admin.Actions') }}
</button>
{{ form_end(form) }}
{% endblock %}
```
- **Always use a single `form_widget(form)`** — see [Twig/CONTEXT.md](../../CONTEXT.md) for why (module hook compatibility)
- The same template typically serves both create and edit — the controller passes different form data
- For file uploads, add `enctype="multipart/form-data"` (see CONTEXT.md)
**Reference:** `src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/` (simple), `src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/` (with image)
## 2. Form theme overrides (only if needed)
When specific fields need custom rendering beyond Symfony defaults:
- **Preferred:** set the `form_theme` option directly on the form (PrestaShop custom option) — usually in the controller when building the form, or in the form type's `configureOptions()`. Symfony picks up the theme automatically; no `{% form_theme %}` directive needed in the Twig file.
- **Fallback:** use the Twig directive when the override is template-specific: