update crud of categories
This commit is contained in:
parent
6afdb366ac
commit
ce25a107f4
|
@ -62,6 +62,18 @@ class CategoryAdminController extends CrudController
|
|||
'button_attr' => ['class' => 'btn btn-sm btn-light'],
|
||||
'raw' => true,
|
||||
])
|
||||
->setField('index', 'Status', ButtonField::class, [
|
||||
'sort' => ['isActive', '.isActive'],
|
||||
'attr' => ['class' => 'miw-100'],
|
||||
'property_builder' => function(EntityInterface $entity) {
|
||||
return $entity->getIsActive() ? 'Actif' : 'Non actif';
|
||||
},
|
||||
'button_attr_builder' => function(EntityInterface $entity) {
|
||||
$class = 'btn btn-sm '.($entity->getIsActive() ? 'btn-success' : 'btn-secondary');
|
||||
|
||||
return ['class' => $class];
|
||||
},
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
|
7
templates/blog/category_admin/field/status.html.twig
Normal file
7
templates/blog/category_admin/field/status.html.twig
Normal file
|
@ -0,0 +1,7 @@
|
|||
{% set map = {
|
||||
0: ['warning', 'Brouillon'],
|
||||
1: ['success', 'Publié'],
|
||||
} %}
|
||||
<button class="btn btn-sm btn-{{ map[entity.status].0 }}">
|
||||
{{ map[entity.status].1 }}
|
||||
</button>
|
Loading…
Reference in a new issue