Documentation » Admin

13. Deleting objects »

« 10. Creating and Editing objects

11. The Show action


This document is a stub representing a new work in progress. If you’re reading this you can help contribute, no matter what your experience level with Sonata is. Check out the issues on Github _ for more information about how to get involved.

This document will cover the Show action and related configuration options.

11.1. Basic configuration

To do:

  • a note about Routes and how disabling them disables the related action
  • a note about lifecycle events triggered by delete?
  • options available when adding general fields, inc custom templates
  • targeting submodel fields using dot-separated notation
  • (Note, if this is very similar to the form documentation it can be combined)

11.2. Customising the query used to show the object from within your Admin class

Setting up a showAction is pretty much the same as a form, which we did in the initial setup.

It is actually a bit easier, because we are only concerned with displaying information.

Smile, the hard part is already done.

The following is a working example of a ShowAction

// src/Acme/DemoBundle/Admin/PostAdmin.php

class ClientAdmin extends Admin
    protected function configureShowFields(ShowMapper $showMapper)
        // Here we set the fields of the ShowMapper variable, $showMapper (but this can be called anything)

             * The default option is to just display the value as text (for boolean this will be 1 or 0)

             * The boolean option is actually very cool
             * - True  shows a check mark and says 'yes'
             * - False shows an 'X' and says 'no'


12. Setting up a custom show template (very useful)

The first thing you need to do is define it in app/config/config/yml:

    title:      Acme Admin Area
    title_logo: img/logo_small.png
        show:       AcmeDemoBundle:Admin:Display_Client.html.twig

Once you have defined this, Sonata Admin looks for it in the following location:


Now that you have told Sonata Admin where to find the template, it’s time to put one in there.

The recommended way to start is to copy the default template, and paste it into it’s new home.

This ensures that you can update Sonata Admin and keep all of your hard work.

The original template can be found in the following location:


Now that you have a copy of the default template, check to make sure it works.

That’s it, now go code.

Found a typo? Something is wrong in this documentation? Just fork and edit it!