用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Guiziweb/guiziweb-plugins --skill add-grid命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | add-grid |
| description | Create an admin grid class (fields, filters, actions) 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.
This skill creates a standalone Grid class. It does not attach the grid to the resource — run /sylius-stack:add-operation Index afterwards to expose it as the index page.
Read src/Entity/{ModelName}.php to retrieve the fields with their names and Doctrine types.
Based on the entity fields, ask the user:
Show action on itemsCreate src/Grid/Admin{ModelName}Grid.php.
Grid name convention: app_admin_{model_snake} (e.g. Book → app_admin_book)
| Doctrine type | Grid field | Notes |
|---|---|---|
string, text | StringField | add ->setSortable(true) when useful |
datetime, date | DateTimeField | default format Y-m-d H:i:s |
integer, float | StringField | plain display |
boolean | TwigField | use @SyliusBootstrapAdminUi/shared/grid/field/boolean.html.twig |
| complex / multi-property | TwigField with ->setPath('.') | gives access to full object in template via {{ data.xxx }} |
StringField:
StringField::create('title')
->setLabel('app.ui.{model_snake}.title')
->setSortable(true),
DateTimeField:
DateTimeField::create('createdAt', 'Y-m-d', null)
->setLabel('app.ui.{model_snake}.created_at'),
TwigField — boolean:
TwigField::create('enabled', '@SyliusBootstrapAdminUi/shared/grid/field/boolean.html.twig')
->setLabel('app.ui.{model_snake}.enabled'),
TwigField — full object (access multiple properties in template):
TwigField::create('summary', 'grid/{model_snake}/field/summary.html.twig')
->setLabel('app.ui.{model_snake}.summary')
->setPath('.'),
{# templates/grid/{model_snake}/field/summary.html.twig #}
<strong>{{ data.title }}</strong>
<p>{{ data.description }}</p>
| Use case | Filter |
|---|---|
| Single string field | StringFilter::create('title') |
| Multiple string fields | StringFilter::create('search')->setOptions(['fields' => ['title', 'description']]) |
| Boolean flag | BooleanFilter::create('enabled') |
| Date range | DateFilter::create('createdAt') |
| Related entity | EntityFilter::create('category', Category::class) |
For an AJAX autocomplete filter on a related entity (useful when the related table is large), use /sylius-stack:add-autocomplete instead — it creates the dedicated filter class and wires it into the grid.
Always include by default:
->addActionGroup(
MainActionGroup::create(
CreateAction::create(),
)
)
->addActionGroup(
ItemActionGroup::create(
UpdateAction::create(),
DeleteAction::create(),
// ShowAction::create(), // uncomment if a show page exists
)
)
->addActionGroup(
BulkActionGroup::create(
DeleteAction::create(),
)
)
->setLimits([10, 25, 50]) // items per page options
// ->orderBy('fieldName', 'asc') // only use a field declared in withFields()
<?php
declare(strict_types=1);
namespace App\Grid;
use App\Entity\{ModelName};
use Sylius\Bundle\GridBundle\Builder\Action\CreateAction;
use Sylius\Bundle\GridBundle\Builder\Action\DeleteAction;
use Sylius\Bundle\GridBundle\Builder\Action\UpdateAction;
use Sylius\Bundle\GridBundle\Builder\ActionGroup\BulkActionGroup;
use Sylius\Bundle\GridBundle\Builder\ActionGroup\ItemActionGroup;
use Sylius\Bundle\GridBundle\Builder\ActionGroup\MainActionGroup;
use Sylius\Bundle\GridBundle\Builder\\;
\\\\\;
\\\\\;
\\\\\;
\\\\\;
\\\\\;
\\\\\;
\\\\;
\\\\;
\\\\;
(
: ,
: {}::,
)
{ModelName}Grid AbstractGrid
{
{
->(
// add fields here
)
->(
// add filters here
)
->([, , ])
->(
::(
::(),
)
)
->(
::(
::(),
::(),
)
)
->(
::(
::(),
)
)
;
}
}
Create or update translations/messages.en.yaml. Use the pattern app.ui.{model_snake}.{field} — one key per field declared in the grid:
app:
ui:
{model_snake}:
{field_1}: '{Field 1 label}'
{field_2}: '{Field 2 label}'
Example for Book with fields title, description, price:
app:
ui:
book:
title: 'Title'
description: 'Description'
price: 'Price'
bin/console cache:clear
bin/console sylius:debug:grid 'App\Grid\Admin{ModelName}Grid'
The grid's fields, filters and actions should be printed.
/sylius-stack:add-operation Index to expose the grid as the admin index page/sylius-stack:add-menu once the index operation exists, to add it to the admin sidebar