A Symfony 4 bundle for allowing drag and drop sorting of entities in list views, incorporating the Sortable Doctrine Extension.

Installs: 252

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 4



1.1 2019-10-15 15:26 UTC

This package is auto-updated.

Last update: 2020-06-15 16:58:54 UTC


This bundle aims to add drag 'n drop sorting to Easy Admin list views, utilizing the sortable doctrine extensions.

PLEASE NOTE This is still under developement, so use at your own risk.

Getting Started


Because this bundle is still under development and yet lacks testing, it is not on Packagist at this time, so you'll need to add the repository to your composer.json file:

// composer.json
"repositories": [
            "url": "",
            "type": "git"

Next install the bundle via composer:

composer require treetop1500/easyadmin-dragndrop-sort

Install Assets

bin/console assets:install --symlink

Configure Gedmo Extensions

You'll need to set up the Gedmo Doctrine Extension for Sortable.

Add Routing

  resource: "@Treetop1500EasyadminDragndropSortBundle/Controller"
  type:     annotation
  prefix: /manage

Javascript and CSS

Ensure that the JS and CSS files are inlcuded in your template via your EasyAdmin Config:

        - '/bundles/treetop1500easyadmindragndropsort/stylesheets/easyadmin-dragndrop-sort.css'
        - '/bundles/treetop1500easyadmindragndropsort/javascripts/easyadmin-dragndrop-sort.js'
        - ''

...or better yet, compile them into your JS and CSS using webpack or another package manager.

// assets/js/app-admin.js

Configure your Entities

All entities should have a $position property which is used as the primary sort method. This property is annotated as a Gedmo SortablePosition property.

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

class Page

     * @var integer $position
     * @Gedmo\SortablePosition()
     * @ORM\Column(name="position", type="integer")
    private $position;

     * @return int
    public function getPosition(): ?int
        return $this->position;
     * @param int $position
    public function setPosition(?int $position)
        $this->position = $position;

Undo list view sorting in Easy Admin Bundle

Because this method utilizes list position in the table to determine the new sort when dropped, you need to disable column head sorting or things get weird. Easy Admin does not include a way to globally turn this off, however you can disable sorting per column by setting sortable: false on each property of the list view:

          - { property: 'position', sortable: false }
          - { property: 'active', sortable: false  }
          - { property: 'ID', label: 'ID', sortable: false  }
          - { property: 'title', sortable: false  }
          - { property: 'slug', sortable: false  }

To Do

  • Set up a flex recipe that will automatically configure the bundle, add routes, add to the kernel and install assets.
  • Extend the configuration to be able to specify which Entity's list views have this functionality.
  • Explore better integration into the Easy Admin bundle by way of extension.
  • Make the admin prefix more dynamic (currently set to "manage")
  • Make the fully qualified class name in the JS more dynamic (currently "App\Entity{Entity}")
  • Test with mobile views
  • Integrate testing
  • Docs