Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
Preview column disappears when modifying Sonata Media Bundle

I am modifying the Sonata Media Bundle's media admin screen to show a new field. After using the Easy Extends tool to extend the bundle, I create a very small class to do this with:

namespace App\Application\Sonata\MediaBundle\Admin\ORM;

use Sonata\AdminBundle\Form\FormMapper;
use Sonata\MediaBundle\Admin\ORM\MediaAdmin as BaseMediaAdmin;

class MediaAdmin extends BaseMediaAdmin
{
    /**
     * {@inheritdoc}
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        parent::configureFormFields($formMapper);

        $formMapper
            ->add(
                'language',
                null,
                []
            )
            ->end();
    }
}

... and I add this in my services.yaml file:

sonata.media.admin.media:
    class: App\Application\Sonata\MediaBundle\Admin\ORM\MediaAdmin
    arguments:
        - ''
        - '%sonata.media.admin.media.entity%'
        - '%sonata.media.admin.media.controller%'
        - '@sonata.media.pool'
        - '@sonata.media.manager.category'
    tags:
        - { name: sonata.admin, manager_type: orm, group: admin, label: Seiten }
    public: true
    calls:
        - [ setModelManager, ["@sonata.media.admin.media.manager"] ]
        - [ setTranslationDomain, ["%sonata.media.admin.media.translation_domain%"] ]
        - [ setTemplates, [ inner_list_row : "@@SonataMedia/MediaAdmin/inner_row_media.html.twig", outer_list_rows_mosaic : "@@SonataMedia/MediaAdmin/list_outer_rows_mosaic.html.twig", base_list_field : "@@SonataAdmin/CRUD/base_list_flat_field.html.twig", list : "@@SonataMedia/MediaAdmin/list.html.twig", edit : "@@SonataMedia/MediaAdmin/edit.html.twig" ] ]

While the new field ("language") loads on my admin screen in the CMS, I find that I now have only half of the fields! The "preview" tab is entirely missing. The fields from the "media" tab are present, but the tab is now labeled as "pages."

Any ideas about what might be going on here?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It turns out that I didn't have to go through the whole baroque dance of redeclaring the service with all dependencies. Instead, all I needed to do in services.yaml was to create a new parameter key pointing at my custom class:

parameters:
    locale: 'de'
    ...
    sonata.media.admin.media.class: 'App\Application\Sonata\MediaBundle\Admin\ORM\MediaAdmin'

After that, everything worked perfectly. Boffo!

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!