Search code examples
symfonysonata-adminsonata-media-bundle

How to show all the context list in Sonata Media Bundle for each module?


I have defined context in sonata_media.yml (below):

sonata_media:
   ....
   contexts:
        default:  # the default context is mandatory
            download:
                strategy: sonata.media.security.public_strategy
                mode: http
            providers:
                - sonata.media.provider.dailymotion
                - sonata.media.provider.youtube
                - sonata.media.provider.image
                - sonata.media.provider.file
            formats:
                small: { width: 150, quality: 95 }
                big:   { width: 500 , quality: 70}

        news:
            download:
                strategy: sonata.media.security.public_strategy
                mode: http
            providers:
                - sonata.media.provider.image
            formats:
                small: { width: 150, quality: 95 }
                big:   { width: 500, quality: 90 }
                wide:  { width: 300, quality: 95 }

I have used context of Image field for Blog module as follow:

->add('image', 'sonata_type_model_list', array('required' => false), array(
                    'link_parameters' => array(
                        'context' => 'news',
                        'hide_context' => true,
                    ),
                ))

By doing this I can see only news context while List / Add / Image (Media model) for Blog module. enter image description here

enter image description here

So how I can add all context / categories for Image field ?


Solution

  • I had face same issue few month back and i just comment "'hide_context' => true," line from add method.

    ->add('image', 'sonata_type_model_list', array('required' => false), array(
                        'link_parameters' => array(
                            'context' => 'news',
                            // 'hide_context' => true,
                        ),
                ))
    

    Try this may it helps you.