PHP-Code:
<?
use Contao\CoreBundle\DataContainer\PaletteManipulator;
/****************************************************************************
Contao-Erweiterung
Zusätzliche Adressfelder für Arbeitsplatz etc
Veraltet: /system/modules/zusatz_member/dca/tl_member.php
Neu ab 4.8: /contao/dca/tl_member.php
****************************************************************************/
/****************************************************************************
Anpassung der Palette
https://contao-academy.de/blog/contao-4-dcaconfig-und-langconfig
Unter Contao 4.8 wurden die Pfade noch einmal angepasst und die Verwendung des
/app-Ordners funktioniert zwar noch, wird allerdings nicht mehr empfohlen.
Die angepassten Contao-Dateien sollten nun in den Ordner /contao und nicht
mehr in den Ordner /app/Resources/contao abgelegt werden.
Die neuen Pfade für unser Beispiel lauten wie folgt:
/contao/dca/tl_content.php
/contao/dca/tl_news.php
/contao/dca/tl_member.php
/contao/languages/de/default.xlf
****************************************************************************/
/****************************************************************************
Zusätzliche Datenbankfelder angelegt
****************************************************************************/
// Datenbankfeld 'email_privat_my' anlegen
// und der Gruppe 'personal' zuordnen
$GLOBALS['TL_DCA']['tl_member']['fields']['privat_email_my'] = [
'label' => &$GLOBALS['TL_LANG']['tl_member']['privat_email_my'],
'exclude' => true,
'inputType' => 'text',
'eval' => ['mandatory'=>false, 'rgxp'=>'email', 'maxlength'=>128, 'placeholder'=>'E-Mail Privat', 'feEditable'=>true, 'feViewable'=>true, 'feGroup'=>'personal', 'tl_class'=>'w50'],
'sql' => "varchar(128) NOT NULL"
];
//Datenbankfeld 'customer_number_my' anlegen
//und der Gruppe 'personal' zuordnen
$GLOBALS['TL_DCA']['tl_member']['fields']['mitglied_number_my'] = [
'label' => &$GLOBALS['TL_LANG']['tl_member']['mitglied_number_my'],
'exclude' => true,
'inputType' => 'text',
'eval' => ['mandatory'=>true, 'rgxp'=>'extnd', 'unique'=>true, 'maxlength'=>8, 'placeholder'=>'Mitgliedernummer', 'feEditable'=>true, 'feViewable'=>true, 'feGroup'=>'personal ', 'tl_class'=>'ctr', 'style'=>'width:128px;'],
'sql' => "int(11) NOT NULL"
];
/*
* Beispiel dateOfBirth in
* /vendor/contao/core-bundle/src/Resources/contao/dca/tl_member.php
* von Leo Feyer
*
* 'dateOfBirth' => array
* (
* 'exclude' => true,
* 'inputType' => 'text',
* 'eval' => array('rgxp'=>'date', 'datepicker'=>true, 'feEditable'=>true, 'feViewable'=>true, 'feGroup'=>'personal', 'tl_class'=>'w50 wizard'),
* 'sql' => "varchar(11) NOT NULL default ''"
* ),
*/
$GLOBALS['TL_DCA']['tl_member']['fields']['mitglied_start_my'] = [
//'label' => &$GLOBALS['TL_LANG']['tl_member']['mitglied_start_my'],
'exclude' => true,
'inputType' => 'text',
'eval' => ['rgxp'=>'date', 'datepicker'=>true, 'feEditable'=>true, 'feViewable'=>true, 'feGroup'=>'personal', 'tl_class'=>'w50 wizard'],
'sql' => "varchar(11) NOT NULL"
];
$GLOBALS['TL_DCA']['tl_member']['fields']['mitglied_stop_my'] = [
//'label' => &$GLOBALS['TL_LANG']['tl_member']['mitglied_stop_my'],
'exclude' => true,
'inputType' => 'text',
'eval' => ['rgxp'=>'date', 'datepicker'=>true, 'feEditable'=>true, 'feViewable'=>true, 'feGroup'=>'personal', 'tl_class'=>'w50 wizard'],
'sql' => "varchar(11) NOT NULL"
];
$GLOBALS['TL_DCA']['tl_member']['fields']['mitglied_memo_my'] = [
'label' => &$GLOBALS['TL_LANG']['tl_member']['mitglied_memo_my'],
'exclude' => true,
'inputType' => 'textarea',
//Wenn 'rows' und 'cols' nicht angegeben werden, setzt Contao automatisch , rows="12", 'cols="20" ein
//'eval' => ['mandatory'=>false, 'rgxp'=>'extnd', 'maxlength'=>1023, 'feEditable'=>true, 'rows'=>1, 'cols'=>1, 'feViewable'=>true, 'feGroup'=>'personal ', 'decodeEntities'=>true, 'tl_class'=>'noresize', 'style'=>'height:64px;'],
'eval' => ['rgxp'=>'extnd', 'maxlength'=>1023, 'placeholder'=>'Bemerkungen', 'feEditable'=>true, 'rows'=>1, 'cols'=>1, 'feViewable'=>true, 'feGroup'=>'personal ', 'decodeEntities'=>true, 'tl_class'=>'ctr', 'style'=>'width:100%;min-height:64px;'],
'sql' => "text NOT NULL"
];
// contao/dca/tl_member.php
// Referenz: https://docs.contao.org/dev/framework/dca/palettemanipulator/
// use Contao\CoreBundle\DataContainer\PaletteManipulator; // Immer an Anfang stellen
PaletteManipulator::create()
// apply the field "privat_email_my" after the field "gender" etc, etc ...
->addField('mitglied_memo_my', 'gender')
->addField('mitglied_stop_my', 'gender')
->addField('mitglied_start_my', 'gender')
->addField('mitglied_number_my', 'gender')
->addField('privat_email_my', 'gender')
// now the field is registered in the PaletteManipulator
// but it still has to be registered in the globals array:
// https://github.com/contao/contao/blob/c9e195891d08bdb26504c394775cf956f23bf719/core-bundle/src/Resources/contao/dca/tl_member.php#L99
->applyToPalette('default', 'tl_member')
;