create-form-typelisted
Install: claude install-skill jeffsenso/prestashop-skills
# create-form-type
Read `@.ai/Component/Forms/CONTEXT.md` for form conventions (base classes, data flow, service registration).
## 1. Root form type
Create `src/PrestaShopBundle/Form/Admin/{Section}/{Domain}/{Domain}Type.php`:
- Extend `TranslatorAwareType` (provides `$this->trans()`) or `AbstractType` for simple forms
- `buildForm()`: add all fields for the entity
- `configureOptions()`: set defaults as needed
- Form types define structure and validation only — no knowledge of commands/queries
**Reference:** `src/PrestaShopBundle/Form/Admin/Improve/International/Tax/TaxType.php` (simple), `src/PrestaShopBundle/Form/Admin/Sell/Catalog/Manufacturer/ManufacturerType.php` (with image)
## 2. Standard field types
| PS field concept | Symfony/PS type | Notes |
|---|---|---|
| Text | `TextType` | Standard input |
| Boolean toggle | `SwitchType` (PS-specific) | On/off switch |
| Select with static options | `ChoiceType` | Inline choices array |
| Select with dynamic options | `ChoiceType` + `ChoiceProvider` | See section 5 |
| Textarea / HTML | `TextareaType` or `FormattedTextareaType` | |
## 3. Translatable fields
For multilingual fields (entity has `_lang` table):
```php
->add('name', TranslatableType::class, [
'type' => TextType::class,
'options' => ['constraints' => [new NotBlank()]],
])
```
- `TranslatableType` renders one input per active shop language
- Submitted data: `['name' => [1 => 'English', 2 => 'French']]`
- Map to command's `setLocalizedNames()` set