diff --git a/docs/crud/configuration.md b/docs/crud/configuration.md
index 726e3ab..854c4c9 100644
--- a/docs/crud/configuration.md
+++ b/docs/crud/configuration.md
@@ -32,9 +32,15 @@ Defines options given to a form.
## setAction
-`setAction(string $page, string $action, bool $enabled)`
+`setAction(string $page, string $action, bool|callable $enabled)`
-Set if an action is enabled or not in the given page. Take a look at `core/Resources/views/admin/crud/*.html.twig` for more information.
+Set if an action is enabled or not in the given page. Take a look at `core/Resources/views/admin/crud/*.html.twig` for more information. Depending the context, the callable could receive the entity in parameter. Example:
+
+```
+->setAction('index', 'edit', function(EntityInterface $entity) {
+ return $entity->getUser()->getId() === $this->getUser()->getId();
+})
+```
Usage in a CRUD template: `{% if configuration.action('index', 'new')%}...{% endif %}`.
@@ -86,7 +92,7 @@ Add a field displayed in the given context. Used in the index.
use App\Core\Crud\Field;
$configuration->setField('index', 'Title', Field\TextField::class, [
- // options
+ // options
])
```
@@ -106,28 +112,28 @@ Examples:
```
$configuration->setField('index', 'My field', TextField::class, [
- 'property' => 'myProperty',
- // OR
- 'property_builder' => function($entity, array $options) {
- return $entity->getMyProperty();
- },
+ 'property' => 'myProperty',
+ // OR
+ 'property_builder' => function($entity, array $options) {
+ return $entity->getMyProperty();
+ },
])
$configuration->setField('index', 'My field', TextField::class, [
- 'raw' => true,
- 'property_builder' => function($entity, array $options) {
- return sprintf('%s', $entity->getBar());
- },
+ 'raw' => true,
+ 'property_builder' => function($entity, array $options) {
+ return sprintf('%s', $entity->getBar());
+ },
])
// https://127.0.0.7:8000/admin/my_entity?_sort=property&_sort_direction=asc
$configuration->setField('index', 'My field', TextField::class, [
- 'property' => 'myProperty'
- 'sort' => ['property', '.myProperty'],
- // OR
- 'sort' => ['property', function(MyEntityRepositoryQuery $query, $direction) {
- $query->orderBy('.myProperty', $direction);
- }],
+ 'property' => 'myProperty'
+ 'sort' => ['property', '.myProperty'],
+ // OR
+ 'sort' => ['property', function(MyEntityRepositoryQuery $query, $direction) {
+ $query->orderBy('.myProperty', $direction);
+ }],
])
```
@@ -198,11 +204,11 @@ Set the default sort applied in the repository query.
```
$configuration
- ->setDefaultSort('index', 'title', 'asc')
- ->setField('index', 'Title', Field\TextField::class, [
- 'property' => 'title',
- 'sort' => ['title', '.title'],
- ]);
+ ->setDefaultSort('index', 'title', 'asc')
+ ->setField('index', 'Title', Field\TextField::class, [
+ 'property' => 'title',
+ 'sort' => ['title', '.title'],
+ ]);
```
## setIsSortableCollection
@@ -214,7 +220,7 @@ It enables the drag & drop to sort entities.
```
class MyEntity implements EntityInterface
{
- // ...
+ // ...
/**
* @ORM\Column(type="integer", nullable=true)
@@ -233,7 +239,7 @@ class MyEntity implements EntityInterface
return $this;
}
- // ...
+ // ...
}
```