so ggf.
PHP-Code:
<?php
$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['eventLocation'] = [
'label' => &$GLOBALS['TL_LANG']['tl_calendar_events']['eventLocation'],
'exclude' => true,
'inputType' => 'select',
'options_callback' => function () {
$modelName = 'mm_event_locations';
$factory = $this->getContainer()->get('metamodels.factory');
$model = $factory->getMetaModel($modelName);
$filter = $model->getEmptyFilter();
$items = $model->findByFilter($filter);
$arrItems = $items->parseAll('text');
$options = [];
// foreach ($items as $item) {
// $options[$item->get('id')] = \sprintf('%s [%s]', $item->get('name'), $item->get('location'));
// }
// dump($arrItems);
foreach ($arrItems as $arrItem) {
$options[$arrItem['raw']['id']] = \sprintf(
'%s [%s]',
$arrItem['text']['name'],
$arrItem['text']['stadt']
);
}
return $options;
},
'eval' => [
'tl_class' => 'w50',
'chosen' => true,
'includeBlankOption' => true,
],
'sql' => "varchar(255) NOT NULL default ''",
];
Lesezeichen