DCA Subpalette für select-Feld
Hallo,
Contao 4.13
Ziel:
in den Artikel-Einstellungen möchte ich ein Feld für ein Hintergrundmedium einrichten.
Auswahl über 'select'
und je nach Auswahl soll ein neuer InputType bereit gestellt werden.
In meinem ersten Versuch möchte ich nur mal 'Hintergrundbild' (addimage) auswählen und dann soll 'inputType' => 'fileTree' bereit gestellt werden. Später dann mal soll noch 'addcolor' hinzukommen und dann sollen andere Felder bereit gestellt werden.
ich habe
PHP-Code:
<?php
use Contao\CoreBundle\DataContainer\PaletteManipulator;
use Contao\System;
PaletteManipulator::create()
->addLegend('articleSpacingLegend', 'template_legend', PaletteManipulator::POSITION_BEFORE)
->addField('sectionOptBackground', 'articleSpacingLegend', PaletteManipulator::POSITION_APPEND)
->addField('addimage', 'articleSpacingLegend', PaletteManipulator::POSITION_APPEND)
$GLOBALS['TL_DCA']['tl_article']['__selector__'][] = 'sectionBackground';
$GLOBALS['TL_DCA']['tl_article']['subpalettes']['sectionBackground'] = 'sectionOptBackground';
$GLOBALS['TL_DCA']['tl_article']['fields']['sectionOptBackground'] = [
'label' => &$GLOBALS['TL_LANG']['tl_article']['sectionOptBackground'],
'inputType' => 'select',
'options' => [
'addimage'
],
'reference' => &$GLOBALS['TL_LANG']['MSC']['optSectionOptBackground'],
'eval' => ['tl_class' => 'w50 clr', 'includeBlankOption' => true, 'chosen' => true],
'sql' => "varchar(255) NOT NULL default ''"
];
$GLOBALS['TL_DCA']['tl_article']['fields']['sectionOptBackground']['addimage'] = [
'label' => &$GLOBALS['TL_LANG']['tl_article']['sectionOptBackgroundImage'],
'exclude' => true,
'inputType' => 'fileTree',
'eval' => [
'files' => true,
'filesOnly' => true,
'fieldType' => 'radio',
'extensions' => \Contao\Config::get('validImageTypes'),
'tl_class' => 'clr',
],
'sql' => ['type' => 'binary', 'length' => 16, 'notnull' => false],
];
Das Auswahlfeld wird mir auch dargestellt. Aber bei Auswahl von 'addimage' passiert dann nichts. 'fileTree' wird mir nicht dargestellt.
Fragen:
- ist das überhaupt möglich?
- hat jemand einen Lösungsansatz für mich?