Issue with Empty SELECT Custom Field in Shopware 6

I’m facing an issue while creating a custom SELECT field in Shopware 6 using a plugin. The custom field is being created successfully, but when I attempt to use the SELECT field in the category settings, the dropdown options appear empty. Instead of showing the expected „ON“ and „OFF“ options, the dropdown displays two empty values.

<?php declare(strict_types=1);

namespace MyNameSpace;

use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\System\CustomField\CustomFieldTypes;
use Shopware\Core\Defaults;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;

class MyClass extends Plugin
{
    public function activate(ActivateContext $activateContext): void
    {
        parent::activate($activateContext);
        
        $context = $activateContext->getContext();
        $this->createCustomField($context);
    }

    private function createCustomField(Context $context): void
    {
        $customFieldRepository = $this->container->get('custom_field_set.repository');

        $customFieldData = [
            'name' => 'categoryNoteSet',
            'config' => [
                'label' => [
                    'en-GB' => 'Categories Notes',
                    'de-DE' => 'Kategorien Hinweise',
                    Defaults::LANGUAGE_SYSTEM => "Categories Notes"
                ]
            ],
            'relations' => [
                [
                   'entityName' => 'category'
                ]
            ],
            'customFields' => [
                // ... Other custom fields
                [
                    'name' => 'noteOfferActivate',
                    'type' => CustomFieldTypes::SELECT,
                    'config' => [
                        'label' => [
                            'en-GB' => 'Activate Offer note',
                            'de-DE' => 'Angebot Hinweis aktivieren',
                            Defaults::LANGUAGE_SYSTEM => "Note Text"
                        ],
                        'options' => [
                            [
                                'label' => [
                                    'en-GB' => 'ON',
                                    'de-DE' => 'An',
                                ],
                                'value' => 'true',
                            ],
                            [
                                'label' => [
                                    'en-GB' => 'OFF',
                                    'de-DE' => 'Aus',
                                ],
                                'value' => 'false',
                            ]               
                        ],
                        'customFieldPosition' => 5
                    ]
                ],
                // ... Other custom fields
            ]
        ];

        $customFieldRepository->create([$customFieldData], $context);
    }
}

that’s how it looks:

Problem Details:

  • I’m creating a custom SELECT field in Shopware 6 using the provided code.
  • The custom field creation is successful with two options: „ON“ and „OFF.“
  • However, upon accessing category settings, the dropdown field for the SELECT option displays two empty values instead of the expected „ON“ and „OFF“ options.

I would greatly appreciate any assistance or guidance on how to resolve this issue. Thank you for your support!

I have exactly the same issue. So far I haven’t found a solution.

Hey @Srcaft, i found the solution, just add the componentName in config like this:

[
    // ...
    'config' => [
        // ...
        'componentName' => 'sw-single-select',
    ],
]