From f61e4b3a44645d9bdd23a883d28d20b4b28cb983 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 14 Apr 2023 06:52:26 +0200 Subject: [PATCH] add doc for crud inline_form --- docs/crud/configuration.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/crud/configuration.md b/docs/crud/configuration.md index a96c73f..84c0929 100644 --- a/docs/crud/configuration.md +++ b/docs/crud/configuration.md @@ -108,10 +108,11 @@ All fields have these options: | `sort` | `array|callable` | `null` | Defines how to sort | | `href` | `string|callable` | `null` | Data to generate a link | | `href_attr` | `array|callable` | `null` | Attributes of the link | +| `inline_form` | `null|callable` | `null` | A method to define a form to edit datas | -Examples: ``` +// Example #0 $configuration->setField('index', 'My field', TextField::class, [ 'property' => 'myProperty', // OR @@ -120,6 +121,7 @@ $configuration->setField('index', 'My field', TextField::class, [ }, ]) +// Example #1 $configuration->setField('index', 'My field', TextField::class, [ 'raw' => true, 'property_builder' => function($entity, array $options) { @@ -127,6 +129,7 @@ $configuration->setField('index', 'My field', TextField::class, [ }, ]) +// Example #2 // https://127.0.0.7:8000/admin/my_entity?_sort=property&_sort_direction=asc $configuration->setField('index', 'My field', TextField::class, [ 'property' => 'myProperty' @@ -136,6 +139,21 @@ $configuration->setField('index', 'My field', TextField::class, [ $query->orderBy('.myProperty', $direction); }], ]) + +// Example #3 +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Validator\Constraints\NotBlank; + +$configuration->setField('index', 'My field', TextField::class, [ + 'property' => 'myProperty', + 'inline_form' => function(FormBuilderInterface $builder, EntityInterface $entity) { + $builder->add('myProperty', TextType::class, [ + 'required' => true, + 'constraints' => [new NotBlank()], + ]); + } +]) ``` ### TextField