# src/Entity/Example.php
namespace App\Entity;
use Runroom\SortableBehaviorBundle\Behaviors\Sortable;
class Example
{
use Sortable;
// ... rest of your class
}
# src/Admin/ExampleAdmin.php
namespace App\Admin;
use Runroom\SortableBehaviorBundle\Admin\SortableAdminTrait;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\ListMapper;
class ExampleAdmin extends AbstractAdmin
{
use SortableAdminTrait;
protected function configureListFields(ListMapper $list): void
{
$list
// ... rest of your list fields
->add(ListMapper::NAME_ACTIONS, ListMapper::TYPE_ACTIONS, [
'actions' => [
// ... rest of your actions
'move' => [
'template' => '@RunroomSortableBehavior/sort.html.twig',
],
],
]);
}
}
protected function configureListFields(ListMapper $list): void
{
$list
// ... rest of your list fields
->add(ListMapper::NAME_ACTIONS, ListMapper::TYPE_ACTIONS, [
'actions' => [
// ... rest of your actions
'move' => [
'template' => '@RunroomSortableBehavior/sort_drag_drop.html.twig',
'enable_top_bottom_buttons' => true, // optional
],
],
]);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.