Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • SensioLabs Professional services to help you with Symfony
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by
  1. Home
  2. Documentation
  3. Bundles
  4. SonataAdminBundle
  5. The Show View

The Show View

Edit this page

Now your admin allows you to create, edit and list blog posts and categories. But what if you just want to have a detailed view of one blog? This chapter will teach you how to use the show view.

If you're still on http://localhost:8000/admin/app/blogpost/list, you'll see a show button on every blog post row. But when you click on it, you end up with a "No form available" message. This is because Sonata doesn't know which fields to show, let's now configure some.

Configuring the Show Mapper

If you're now familiar with the FormMapper and the ListMapper, the ShowMapper will look very similar:

1
2
3
4
5
6
7
8
9
10
11
12
13
// src/Admin/BlogPostAdmin.php

use Sonata\AdminBundle\Show\ShowMapper;

protected function configureShowFields(ShowMapper $show): void
{
    $show
        ->add('id')
        ->add('title')
        ->add('body')
        ->add('category.name')
    ;
}

Using Groups and tabs

Like the FormMapper, the ShowMapper also supports grouping fields together:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// src/Admin/BlogPostAdmin.php

protected function configureShowFields(ShowMapper $show): void
{
    $show
        ->tab('Post')
            ->with('Content', ['class' => 'col-md-9'])
                // ...
            ->end()
            ->with('Meta data', ['class' => 'col-md-3'])
                // ...
            ->end()
        ->end()

        ->tab('Publish Options')
            // ...
        ->end()
    ;
}

Round Up

You've learned how to find posts to edit, how to create a nice list view, how to add options to search, order and filter this list. Now you've learned how to display the details of one post.

There might have been some very difficult things, but imagine the difficulty writing everything yourself! As you're now already quite good with the basics, you can start reading other articles in the documentation, like:

  • Customizing the Dashboard
  • Configuring the Security system
  • Adding export functionality
  • Adding a preview page
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

    Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

    Make sure your project is risk free

    Make sure your project is risk free

    Version:

    Table of Contents

    • Configuring the Show Mapper
    • Using Groups and tabs
    • Round Up

    Symfony footer

    Avatar of Adam Bramley, a Symfony contributor

    Thanks Adam Bramley for being a Symfony contributor

    1 commit • 4 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • What is Symfony?
      • Symfony at a Glance
      • Symfony Components
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • Symfony Community
      • SymfonyConnect
      • Events & Meetups
      • Projects using Symfony
      • Contributors
      • Symfony Jobs
      • Backers
      • Code of Conduct
      • Downloads Stats
      • Support
    • Blog

      • All Blog Posts
      • A Week of Symfony
      • Case Studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Living on the edge
      • Releases
      • Security Advisories
      • Symfony Insight
      • Twig
      • SensioLabs Blog
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Powered by

    Follow Symfony