agentsclimarketplace

Create form type

Skill jeffsenso/prestashop-skills/skills/prestashop-module-development/ps9-core-ai/Component/Forms/skills/create-form-type

Prestashop Developer Skills

Install
npx -y skills add jeffsenso/prestashop-skills --skill create-form-type

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Create the Symfony form type for an entity's add/edit form. Covers standard field types, translatable fields, money fields, file uploads, and choice providers. For multi-tab layout with NavigationTabType, see create-form-tab-layout. Trigger: "create form type for {Domain}".

SKILL.md

3.4 KB, as published. Nobody here has run it

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 conceptSymfony/PS typeNotes
TextTextTypeStandard input
Boolean toggleSwitchType (PS-specific)On/off switch
Select with static optionsChoiceTypeInline choices array
Select with dynamic optionsChoiceType + ChoiceProviderSee section 5
Textarea / HTMLTextareaType or FormattedTextareaType

3. Translatable fields

For multilingual fields (entity has _lang table):

->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() setter in the DataHandler

For translatable textareas: wrap TextareaType or FormattedTextareaType.

4. Money / price fields

For monetary fields (see Forms/CONTEXT.md for decimal scale convention):

  • Static currency: MoneyType::class with 'currency' => $defaultCurrencyIsoCode
  • Multi-currency: PS-specific AmountType if available
  • Use appropriate transformers to convert between form display and storage

5. Choice providers

For select fields with dynamic options from DB:

  • Create {Domain}{Field}ChoiceProvider.php implementing ChoiceProviderInterface
  • Inject repository or DBAL connection
  • getChoices(): array — return ['Label' => value] array
  • Inject into the form type and pass as choices option

Reference: src/Core/Form/ChoiceProvider/ (61+ existing providers)

6. File upload fields

For image/logo uploads (see Forms/CONTEXT.md for file upload conventions):

  • Add FileType::class with 'mapped' => false, 'required' => false
  • Add File constraint with allowed MIME types
  • Display existing image in the edit template via custom Twig block

Rules

Conventions (base classes, file uploads, choice providers, NavigationTabType) are in Forms/CONTEXT.md. Skill-specific reminders:

  • Add Symfony validation constraints directly on form fields (NotBlank, Length, Regex)
  • For multi-tab layout, use the create-form-tab-layout skill instead

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.