com um clique
add-form
Add an admin FormType for an existing Sylius Resource
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
Add an admin FormType for an existing Sylius Resource
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
Implement the fix described in a GitHub issue and open a Pull Request that closes it
Apply the latest review feedback to a Pull Request and push it to the PR branch
Add an admin autocomplete form type for a Sylius Resource (translatable or not), optionally injected into another form via an extension
Add a Sylius admin grid for an existing Sylius Resource
Add a multiple images collection (OneToMany) to an existing Sylius Resource
Add an admin menu entry for an existing Sylius Resource
| name | add-form |
| description | Add an admin FormType for an existing Sylius Resource |
| argument-hint | [ModelName] |
| allowed-tools | AskUserQuestion, Bash, Read, Edit, Write, Glob, Grep |
Ask the user for the ModelName if not provided. Read src/**/Entity/{ModelName}/{ModelName}.php to detect the entity's fields.
Prerequisite: the model must already exist as a Sylius Resource (run /sylius-app:add-model first).
src/Form/Type/{ModelName}/{ModelName}Type.php:
<?php
declare(strict_types=1);
namespace App\Form\Type\{ModelName};
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Symfony\Component\Form\FormBuilderInterface;
final class {ModelName}Type extends AbstractResourceType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
// add fields based on the entity properties
;
}
public function getBlockPrefix(): string
{
return 'app_{model_snake}';
}
}
Read the entity fields and add the appropriate Symfony form types for each one (e.g. TextType, TextareaType, IntegerType, CheckboxType, etc.). Label each field with app.form.{model_snake}.{field}:
$builder
->add('name', TextType::class, [
'label' => 'app.form.{model_snake}.name',
])
->add('enabled', CheckboxType::class, [
'label' => 'app.form.{model_snake}.enabled',
])
;
Add to config/services.yaml:
services:
app.form.type.{model_snake}:
class: App\Form\Type\{ModelName}\{ModelName}Type
arguments:
- '%app.model.{model_snake}.class%'
- ['sylius']
tags:
- { name: form.type }
Edit config/packages/sylius_resource.yaml. Add form: under the existing classes: for app.{model_snake}:
sylius_resource:
resources:
app.{model_snake}:
driver: doctrine/orm
classes:
model: App\Entity\{ModelName}\{ModelName}
interface: App\Entity\{ModelName}\{ModelName}Interface
form: App\Form\Type\{ModelName}\{ModelName}Type
Get the project's default locale:
bin/console debug:container --parameter=kernel.default_locale
Add labels to translations/messages.{locale}.yaml under app.form.{model_snake}.{field} (one entry per field declared in the FormType):
app:
form:
{model_snake}:
name: Name
enabled: Enabled
# one entry per field
bin/console cache:clear
bin/console debug:form "App\Form\Type\{ModelName}\{ModelName}Type" lists the declared fieldsbin/console debug:translation {locale} --domain=messages 2>&1 | grep 'app.form.{model_snake}' lists every field label you added./sylius-app:add-grid to add the admin index grid/sylius-app:add-routes and /sylius-app:add-menu to wire it into the admin/sylius-app:add-images if the model needs an images collection/sylius-app:add-autocomplete to expose the model as a searchable field in another form