diff --git a/docs/cookbook/admin_panel/basic_operations.md b/docs/cookbook/admin_panel/basic_operations.md index 3f8b1456..d8b09f9a 100644 --- a/docs/cookbook/admin_panel/basic_operations.md +++ b/docs/cookbook/admin_panel/basic_operations.md @@ -21,20 +21,38 @@ bin/console cache:clear # To refresh grid's cache Magic! Here is the generated grid. +{% code title="src/Grid/BookGrid.php" lineNumbers="true" %} ```php -final class BookGrid extends AbstractGrid implements ResourceAwareGridInterface +
Book creation page
-Create a form type for your resource. +Create a form type for your resource. You can use the Symfony command to generate your form fields. ```shell bin/console make:form ``` +Here is a basic example of a FormType for your Book resource. + +{% code title="src/Form/BookType.php" lineNumbers="true" %} +```php +add('author', EntityType::class, [ + 'class' => Author::class, + 'choice_label' => 'id', + ]) + ->add('title', TextType::class) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Book::class, + ]); + } +} +``` +{% endcode %} + Configure the `create` operation in your resource. +{% tabs %} +{% tab title="Sylius" %} +{% code title="src/Entity/Book.php" lineNumbers="true" %} ```php +