Verwendung: Custom Elements: 'dependsOn' innerhalb 'list'
Produkt: Custom Elements Contao
Contao-Version: 4.19
Hallo Rocksolid-Team,
ich möchte für TAO ein komplexes Inhaltselement mit den RSCE erstellen. Dies soll auf der Basis des "Boxes"-Elements aufgebaut werden. Allerdings sollen die Boxen eine unterschiedliche Inhaltsstruktur nach Wahl haben können.
Die Auswahl der 'inputType' per 'select' über 'dependsOn' klappt auch grundsätzlich.
Sobald ich die Blocks aber in ein 'list' packe, wird das 'dependsOn' nicht mehr ausgewertet.
Das erscheint mir auch logisch, da durch 'list' eine Array-Ebene hinzukommt.
Die Frage ist also: Wie muss 'field' lauten, damit 'value' ausgewertet wird?
...
'dependsOn' => ['field' => ??? ,'value' => '1'],
...
Das Schema soll wie folgt aussehen (es gibt mehr Blocktypen und die einzelnen Blocks sind auch komplexer aufgebaut):
return [
'label' => ['Unterschiedliche Blocks', ''],
'types' => ['content'],
'standardFields' => ['cssID'],
'fields' => [
'blocks' => [
'label' => ['Blocks', ''],
'elementLabel' => '%s. Block',
'inputType' => 'list',
'minItems' => 3,
'maxItems' => 3,
'fields' => [
'blockType' => [
'label' => ['Dieser Block ist ein:', ''],
'inputType' => 'select',
'options' => [
'0' => 'Bitte auswählen',
'1' => 'Textblock',
'2' => 'Bildblock ',
],
'eval' => ['submitOnChange'=>true, 'tl_class'=>'w50'],
],
'blockTxt' => [
'label' => ['Text', ''],
'inputType' => 'text',
'eval' => [...],
'dependsOn' => [
'field' => ['blocks' => 'blockType'],
'value' =>'1'
],
],
'blockImg' => [
'label' => ['Bild', ''],
'inputType' => 'fileTree',
'eval' => [...],
'dependsOn' => [
'field' => ['blocks' => 'blockType'],
'value' =>'2'
],
],
],
],
],
]
Danke und viele Grüße
Andreas
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Andreas on 02 Oct, 2022 06:07 AM
Hat sich erledigt.
Es funktionierte, nachdem ich aus den options des select die Option
entfernt und stattdessen die 'includeBlankOption' zum select hinzugefügt hatte.'dependsOn' lautet dann ganz normal:
Ein Basisschema für ein Element könnte dann z.B. so aussehen:
Danke und Gruß
Andreas