# Definition Customfields in theme.php in Theme-Plugin

**URL:** <https://forum.shopware.com/t/definition-customfields-in-theme-php-in-theme-plugin/108240>\
**Category:** Themes & Design\
**Created:** [17. November 2025 um 07:48 UTC](https://forum.shopware.com/t/definition-customfields-in-theme-php-in-theme-plugin/108240 "2025-11-17T07:48:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![timon.haeslich](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@timon.haeslich](https://forum.shopware.com/u/timon.haeslich)\
**Post date:** [17. November 2025 um 07:48 UTC](https://forum.shopware.com/t/definition-customfields-in-theme-php-in-theme-plugin/108240/1 "2025-11-17T07:48:01Z")

</div>

Ich definiere meine Customfields in meiner Theme.php im src Ordner.  
Das funktioniert erfolgreich mit Text- und Text-Editor-Feldern.

Beispiel:

$this-\>createCustomFieldSet($customFieldSetRepository, $context, [

```
'name' => 'custom_category',

'label' => \['de-DE' => 'Kategorien'\],

'relations' => \[\['entityName' => 'category'\]\],

'customFields' => \[

    \[

        'name' => 'custom_category_description_bottom',

        'type' => 'textEditor',

        'config' => \[

            'label' => \['de-DE' => 'SEO-Text unterhalb Produktlisting'\],

            'componentName' => 'sw-text-editor',

            'customFieldPosition' => 1

        \]

    \]

\]

```

]);

Nun möchte ich aber ein Customfield mit einem Aktiv-Schalter anlegen. Das habe ich so versucht:

$this-\>createCustomFieldSet($customFieldSetRepository, $context, [

```
'name' => 'custom_category',

'label' => \['de-DE' => 'Kategorien'\],

'relations' => \[\['entityName' => 'category'\]\],

'customFields' => \[

    \[

        'name' => 'custom_category_show_startpage',

        'type' => 'bool',

        'componentName' => 'sw-field',

        'config' => \[

            'type' => 'switch',

            'label' => \['de-DE' => 'auf Startseite anzeigen'\],                      

            'customFieldPosition' => 2

        \]

    \]

\]

```

]);

Leider funtkioniert das nicht, der Typ wird nicht gesetzt und bleibt leer.

Gibt es irgendwo eine Auflisting, wie die Typen definiert werden müssen? Ich habe leider nirgends was gefunden.

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [17. November 2025 um 08:42 UTC](https://forum.shopware.com/t/definition-customfields-in-theme-php-in-theme-plugin/108240/2 "2025-11-17T08:42:13Z")

</div>

> **[Add Custom Field | Shopware Documentation](https://developer.shopware.com/docs/guides/plugins/plugins/framework/custom-field/add-custom-field.html#add-a-custom-field-to-the-administration)**
>
> Documentation for Shopware developers

---

<div class="post-metadata">

**Author:** ![timon.haeslich](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@timon.haeslich](https://forum.shopware.com/u/timon.haeslich)\
**Post date:** [17. November 2025 um 12:30 UTC](https://forum.shopware.com/t/definition-customfields-in-theme-php-in-theme-plugin/108240/3 "2025-11-17T12:30:56Z")

</div>

Hallo @Max_Shop ,

ich kenne diese Seite, aber ich finde dort nirgends die Definition eines Aktiv-Schalters.

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [17. November 2025 um 12:41 UTC](https://forum.shopware.com/t/definition-customfields-in-theme-php-in-theme-plugin/108240/4 "2025-11-17T12:41:13Z")

</div>

Hast du es mal in dem Format getestet?

> <https://github.com/shopware/shopware/blob/77f18cd1cb18f8ec4c6289d75dfeab031980f732/src/Core/Framework/Demodata/Generator/CustomFieldGenerator.php>

SWITCH ist korrekt:

> <https://github.com/shopware/shopware/blob/77f18cd1cb18f8ec4c6289d75dfeab031980f732/src/Core/System/CustomField/CustomFieldTypes.php>
