Skip to content
Back to skills

Create Twig Form Template

ASecurity

Create the Twig template for the add/edit form page. Renders the Symfony form, save buttons, and optional form theme overrides for custom field rendering. Trigger: "create form template for {Domain}".

  • 6 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 29, 2026
ai-agentsjavascriptjavavue

Security analysis

A100/100

Scanned May 29, 2026

npx -y skills add jeffsenso/prestashop-skills --skill create-twig-form-template --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Create Twig Form Template?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Create Twig Form Template
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jeffsenso-create-twig-form-template/badge)](https://www.skillsdirectory.com/skills/jeffsenso-create-twig-form-template)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: create-twig-form-template
description: >
  Create the Twig template for the add/edit form page. Renders the Symfony form,
  save buttons, and optional form theme overrides for custom field rendering.
  Trigger: "create form template for {Domain}".
needs: [create-form-type, create-controller-form-actions, create-admin-routing]
produces: "form.html.twig — add/edit form page template"
subagent: optional
---

# 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:
  `{% form_theme form 'Admin/{Section}/{Domain}/{domain}_theme.html.twig' %}`
- Override the field block: `{% block _{field_id}_widget %}...{% endblock %}`
- Common case: image preview next to upload field with a "Remove" checkbox

Form themes are scoped to this form only — no global side effects.

## 3. JS asset inclusion

If the form needs JavaScript (for `initComponents` or Vue):

```twig
{% block javascripts %}
  {{ parent() }}
  <script src="{{ asset('themes/new-theme/public/{domain}.bundle.js') }}"></script>
{% endblock %}
```

The asset path must match the webpack entry name.

## Rules

Conventions (layout, `path()`, single `form_widget(form)`, NavigationTabType auto-rendering, file upload enctype, form theme block naming, JS asset inclusion) are in [Twig/CONTEXT.md](../../CONTEXT.md). Skill-specific reminders:

- Form theme overrides should be minimal — Symfony's default rendering handles most cases
- CSRF token is included automatically by `form_end(form)`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.