Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

254
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda