Files
survey-bundle/contao/dca/tl_survey_condition.php
T
2026-05-29 10:19:19 +02:00

96 lines
3.6 KiB
PHP

<?php
declare(strict_types=1);
use Contao\DC_Table;
use Mummert\SurveyBundle\EventListener\SurveyDcaListener;
$guardCallback = [SurveyDcaListener::class, 'guardConditionSave'];
$GLOBALS['TL_DCA']['tl_survey_condition'] = [
'config' => [
'dataContainer' => DC_Table::class,
'ptable' => 'tl_survey',
'enableVersioning' => true,
'onload_callback' => [
[SurveyDcaListener::class, 'restrictSurveyConditionEditing'],
],
'onsubmit_callback' => [
[SurveyDcaListener::class, 'touchSurveyConditionParent'],
],
'ondelete_callback' => [
[SurveyDcaListener::class, 'guardConditionDelete'],
[SurveyDcaListener::class, 'touchSurveyConditionParent'],
],
'sql' => [
'keys' => [
'id' => 'primary',
'pid' => 'index',
'sourceQuestion' => 'index',
'targetQuestion' => 'index',
],
],
],
'list' => [
'sorting' => [
'mode' => 4,
'fields' => ['id'],
'headerFields' => ['title', 'alias', 'published', 'isLocked'],
'panelLayout' => 'sort,search,limit',
],
'label' => [
'fields' => ['sourceQuestion', 'answerValue', 'targetQuestion'],
'showColumns' => true,
],
'operations' => [
'edit' => [
'href' => 'act=edit',
'icon' => 'edit.svg',
],
'copy' => [
'href' => 'act=copy',
'icon' => 'copy.svg',
],
'delete' => [
'href' => 'act=delete',
'icon' => 'delete.svg',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich löschen?\'))return false;Backend.getScrollOffset()"',
],
'show' => [
'href' => 'act=show',
'icon' => 'show.svg',
],
],
],
'palettes' => [
'default' => '{logic_legend},sourceQuestion,answerValue,targetQuestion',
],
'fields' => [
'id' => ['sql' => 'int(10) unsigned NOT NULL auto_increment'],
'tstamp' => ['sql' => 'int(10) unsigned NOT NULL default 0'],
'pid' => ['sql' => 'int(10) unsigned NOT NULL default 0'],
'sourceQuestion' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_condition']['sourceQuestion'],
'inputType' => 'select',
'options_callback' => [SurveyDcaListener::class, 'getQuestionOptions'],
'eval' => ['mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'answerValue' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_condition']['answerValue'],
'inputType' => 'text',
'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'],
'save_callback' => [$guardCallback],
'sql' => "varchar(255) NOT NULL default ''",
],
'targetQuestion' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_condition']['targetQuestion'],
'inputType' => 'select',
'options_callback' => [SurveyDcaListener::class, 'getQuestionOptions'],
'eval' => ['mandatory' => true, 'includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'clr'],
'save_callback' => [$guardCallback],
'sql' => 'int(10) unsigned NOT NULL default 0',
],
],
];