How to use <sw-media-list-selection/> in Shopware 6?

Viewed 756

I'm building a custom cms element following that guide https://docs.shopware.com/en/shopware-platform-dev-en/how-to/custom-cms-element?category=shopware-platform-dev-en/how-to source code is at the end of the guide. For my element (Custom Image Slider) I need multiple image selection, so inside config template(.html.twig) I use sw-media-list-selection (https://component-library.shopware.com/components/sw-media-list-selection).

But there is a problem when I try to configure new element settings (admin panel -> Content -> Shopping Experiences) I can only upload new images (both from PC and URl) but that new Images is not adding to the selected grid (two columns is always empty) Also "Open media" button is not working. My main thought is there is a problem with my config twig.html file or defaultConfig. I'm new to shopware 6 and I will appreciate any help.

Here is my config template(.html.twig)

{% block sw_cms_element_image_config %}
<div class="sw-cms-el-config-slider">
   <sw-media-list-selection class="sw-cms-el-config-slider__media-selection"
          :entityMediaItems="element.config.entityMediaItems.value"
          :entity="element.config.entity.value"
          :defaultFolder="element.config.defaultFolder.value"
          :uploadTag="element.config.uploadTag.value">
   </sw-media-list-selection>
</div>
{% endblock %}

And there is my defaultConfig inside Shopware.Service('cmsService').registerCmsElement();

defaultConfig: {
        entityMediaItems: {
            value: []
        },
        entity: {
            value: {
                isLoading: false,
                id: "myUploadTag"
            }
        },
        uploadTag: {
            source: 'static',
            value: "myUploadTag"
        },
        defaultFolder: {
            source: 'static',
            value: "media"
        },
    }

Ps. sw-media-list-selection-v2 is not working at all

Ps 2. Thanks for your time.

0 Answers
Related