#hoopla

  • Startseite
  • Kontakt
  • Hoopla?!
  • Datenschutz
  • Impressum
  • « Convert/ImageMagick: not authorized `pdf:-'
  • How to run legacy PHP application (Symfony 1.4) on current Ubuntu with Docker »

Symfony 3.4: make Sonata list sortable using YAML for entitiy definition

Eingetragen von fayon am 20 Okt 2018 in Arbeit

I used the manual from https://github.com/sonata-project/SonataAdminBundle/blob/3.x/docs/cookbook/recipe_sortable_listing.rst, but it did not work for me. In fact, it contained too many bundles for my setup making the installation overly complicated. Furthermore, there is a pitfall when using YML files for entities. Using YML is supported, but not well documented and if annotations (as in the manual) are used together with YML, the annotations will be ignored. In order to get it working I needed to do the following steps.

Install the prerequisites gedmo/doctrine-extensions and pixassociates/sortable-behavior-bundle via composer. Activate the Sortable bundle in AppKernel:

new Pix\SortableBehaviorBundle\PixSortableBehaviorBundle(),

Add position field to Doctrine YML and update the entity PHP and database as usual:

fields:
        position:
            type: integer
            nullable: true
            column: position
            gedmo:
                - sortablePosition

In the Sonata Admin class add the following:

protected $datagridValues = [
        '_page' => 1,
        '_sort_order' => 'ASC',
        '_sort_by' => 'position',
    ];

protected function configureListFields(ListMapper $listMapper)
    {
        ...
        $listMapper
            ->add('_action', null, [
                'actions' => [
                    'move' => [
                        'template' => '@PixSortableBehavior/Default/_sort.html.twig',
                        'enable_top_bottom_buttons' => true,
                    ],
                ]
            ]);
    }

    protected function configureRoutes(RouteCollection $collection)
{
    // ...
    $collection->add('move', $this->getRouterIdParameter().'/move/{position}');
}

Activate the Sortable Admin for this entity in services.yml:

admin.lineitem:
        class: Ond\ErpBundle\Admin\LineItemAdmin
        arguments: 
            - ~
            - Ond\ErpBundle\Entity\LineItem
            - 'PixSortableBehaviorBundle:SortableAdmin'
        tags:
            - { name: sonata.admin, manager_type: orm, label: Line Item, show_in_dashboard: false }
        public: true

Dieser Eintrag wurde eingetragen von fayon und ist abgelegt unter Arbeit.

Noch kein Feedback


Formular wird geladen...

Kommentar-Feed für diesen Eintrag

Suche

Neueste Posts

  • MariaDB boolean comparison syntax
  • Software archeology: how to send customized HTML mails with Drupal 7
  • Connect to IP-restricted Azure MSSQL database via tunnel
  • Postgres: Convert numeric currency value to German bookkeeping standard
  • Computer scientist's way to clean up a room for online conferences
  • JTL5 + Nova Template + Youtube: "Dieses Video ist nicht verfügbar"
  • JTL5 + Nova Child Template + Google Analytics 4
  • Office 365: SMTP with Basic Auth made (im)possible
  • How to migrate from Exchange to Office365
  • Install Ubuntu 20 with a USB flash drive. Go for the old-fashioned way.

Neueste Kommentare

  • Katrin am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • Inga am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • Pulsotronic-Anlagentechnik GmbH am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • Stephan am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • Lopez am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • Heike am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • Renata am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • Sandman am Kopierstempel in Photoshop innerhalb VirtualBox funktioniert nicht
  • treviris am Kopierstempel in Photoshop innerhalb VirtualBox funktioniert nicht
  • Mike am Netzwerkscanner auf Ubuntu einrichten
  • Carlos am Nautilus 3.10 on Ubuntu 14.04: Show full date and time in list view column
  • Carlos am Nautilus 3.10 on Ubuntu 14.04: Show full date and time in list view column
  • Mohsen am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • David am Nautilus 3.10 on Ubuntu 14.04: Show full date and time in list view column
  • Conny am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • Markus am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • SK am Elster: Zertifikat verlängern gibt "Es ist ein Fehler aufgetreten! Bitte starten Sie den Browser erneut und führen Sie diese Aktion nochmal durch."
  • Menzel am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"
  • Angelika am Elster: Zertifikat verlängern gibt "Es ist ein Fehler aufgetreten! Bitte starten Sie den Browser erneut und führen Sie diese Aktion nochmal durch."
  • Michael am IAA Plus: Fehlermeldung "Ware(X). Aussenhandelsstatistik Menge.fehlende Pflichtfeld"

©2022 by ff • Kontakt • Hilfe

Website builder