Skip to content

Commit

Permalink
[Docs] Init resource creation
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Dec 9, 2024
1 parent 77c73fc commit 5a4d6db
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Binary file added docs/.gitbook/assets/book_creation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions docs/cookbook/admin_panel/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,45 @@ Your route should look like this.
app_admin_book_index /admin/books
```

## How to add a resource creation page

<div data-full-width="false">

<figure><img src="../../.gitbook/assets/book_creation.png" alt="Book creation page"></figure>

</div>

Create a form type for your resource.

```shell
bin/console make:form

Configure the `create` operation in your resource.

```php
namespace App\Entity;
use App\Form\BookType;
use Sylius\Resource\Metadata\AsResource;
use Sylius\Resource\Metadata\Create;
use Sylius\Resource\Model\ResourceInterface;
#[AsResource(
section: 'admin', // This will influence the route name
routePrefix: '/admin',
templatesDir: '@SyliusAdminUi/crud', // This directory contains the generic template for your list
formType: BookType::class, // The form type you have generated in previous step
operations: [
// ...
new Create(), // This operation will add "create" operation for the book resource
],
)]
class Book implements ResourceInterface
{
//...
}
```

## How to customize the sidebar logo

To customize the sidebar logo, you need to set new logo template at `sylius_admin.common.component.sidebar.logo` twig hook.
Expand Down

0 comments on commit 5a4d6db

Please sign in to comment.