torfs-ict / ea-sortable-bundle
Sortable entities in EasyAdmin bundle with drag-and-drop interface
Installs: 867
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 5
Open Issues: 3
Language:JavaScript
Type:symfony-bundle
pkg:composer/torfs-ict/ea-sortable-bundle
Requires
This package is auto-updated.
Last update: 2025-10-26 12:24:36 UTC
README
This bundle provides a convenient way to make your entities sortable as well as a drag-and-drop in the EasyAdmin list view.
The javascript and css was copied from treetop1500/easyadmin-dragndrop-sort with some minor improvements.
Installation
Install the bundle using composer:
$ composer req torfs-ict/ea-sortable-bundle
Add the bundle routing to config/routes.yaml:
ea-sortable: resource: '@OrkestraEaSortableBundle/Controller/' type: annotation
Usage
Using the sortable trait
Add the Orkestra\EaSortable\SortableTrait trait to your entity. Below is the sample configuration for
EasyAdmin.
easy_admin: entities: SortableEntity: class: App\Entity\SortableEntity list: sort: ['position', 'ASC'] actions: - delete - edit - new - search - { name: sort, template: '@OrkestraEaSortable/ea-sortable.html.twig' } fields: - { property: id, label: '$Id', sortable: false } - { property: name, label: Name, sortable: false }
Some notes about the configuration:
- setting the
sortoption is mandatory, obviously - you need to provide the custom
sortaction in order to enable the drag-and-drop functionality - sorting must be disabled on all other list fields (there is no way to do this globally in EasyAdmin)
Without the sortable trait
As long as your sorting property is called position you can simply follow the same steps as when
using the sortable trait. If not you need to do the following things:
- change the property in the
sortoption - configure the property on the
sortaction
The following example assumes the sorting property is named index.
easy_admin: entities: SortableEntity: class: App\Entity\SortableEntity list: sort: ['index', 'ASC'] actions: - delete - edit - new - search - { name: sort, template: '@OrkestraEaSortable/ea-sortable.html.twig', property: index } fields: - { property: id, label: '$Id', sortable: false } - { property: name, label: Name, sortable: false }