Ergebnis 1 bis 5 von 5

Thema: [gelöst] ]Fehlende Überschriften/HeaderFields

  1. #1
    Contao-Nutzer
    Registriert seit
    18.06.2017.
    Beiträge
    220

    Standard [gelöst] ]Fehlende Überschriften/HeaderFields

    Hallo,

    ich versuche gerade in einem List die HeaderFields hinzuzufügen.

    Code:
    'list' => [
            'sorting' => [
                'mode' => 4,
                'fields' => ['sorting','tasting_bottle_name'],
                'headerFields' => ['tasting_bottle_name'],
                'panelLayout' => 'search,limit',
                'disableGrouping' => true,
                'child_record_callback' => ['tl_tasting_details', 'getTastingBottles'],
            ],
    Es werden aber kein Feld angezeigt. Sollte nicht zumindest 'tasting_bottle_name' dort auftauchen?
    Geändert von darkness (14.01.2021 um 10:47 Uhr)

  2. #2
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    37.209
    Partner-ID
    10107

    Standard

    Poste dein komplettes DCA und einen Screenshot vom Backend.

  3. #3
    Contao-Nutzer
    Registriert seit
    18.06.2017.
    Beiträge
    220

    Standard

    Hier das DCA. Gibt es gerade Probleme im Forum mit dem Upload. Beim Klick auf Anhänge verwalten bekomme ich nur ein graues Fenster.

    Code:
    <?php
    // contao/dca/tl_tasting_details.php
    
    use Contao\Database;
    use Contao\Input;
    
    $GLOBALS['TL_DCA']['tl_tasting_details'] = [
        'config' => [
            'dataContainer' => 'Table',
            'ptable' => 'tl_tasting',
            'sql' => [
                'keys' => [
                    'id' => 'primary'
                ],
            ],
            'onload_callback' => [
                function () {
                    $db = \Contao\Database::getInstance();
                    $pid = \Contao\Input::get('pid');
                    $result = $db->prepare('SELECT `tasting_date` FROM `tl_tasting` WHERE `id` = ?')
                    ->execute([$pid]);
                    //$prefix = strtoupper(substr($result->name, 0, 2));
                    //$GLOBALS['TL_DCA']['tl_parts']['fields']['number']['default'] = $prefix;
                    },
                ]
            ],
        'list' => [
            'sorting' => [
                'mode' => 4,
                'fields' => ['sorting','tasting_bottle_name'],
                'headerFields' => ['tasting_bottle_name'],
                'panelLayout' => 'search,limit',
                'disableGrouping' => true,
                'child_record_callback' => ['tl_tasting_details', 'getTastingBottles'],
            ],
            'operations' => [
                'editheader' => [
                    'href' => 'act=edit',
                    'icon' => 'header.svg',
                ],
                'delete' => [
                    'href' => 'act=delete',
                    'icon' => 'delete.svg',
                ],
                'show' => [
                    'href' => 'act=show',
                    'icon' => 'show.svg'
                ],
            ],
        ],
        'fields' => [
            'id' => [
                'sql' => ['type' => 'integer', 'unsigned' => true, 'autoincrement' => true],
            ],
            'pid' => [
                'foreignKey' => 'tl_tasting.tasting_date',
                'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0],
                'relation' => ['type'=>'belongsTo', 'load'=>'lazy']
            ],
            'sorting' => [
                'sql' => "int(10) unsigned NOT NULL default 0"
            ],
            'tstamp' => [
                'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0]
            ],
            'tasting_bottle_name' => [
                'label'                 => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_bottle_name'],
                'inputType'             => 'select',
                //'options'               => $GLOBALS['TL_LANG'][$table]['tl_tasting_bottle']['bottle_name'],
                'foreignKey'            => 'tl_tasting_bottle.id',
                'search'                => true,
                'options_callback'      => ['tl_tasting_details', 'getBottles'],
                'eval'                  => ['includeBlankOption'=>true, 'tl_class'=>'w50'],
                'sql'                   => "varchar(255) NOT NULL default ''"
            ],
            'tasting_bottle_name_extra' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_bottle_name_extra'],
                'inputType' => 'text',
                'eval' => ['tl_class' => 'w50', 'maxlength' => 255],
                'load_callback'    => ['tl_tasting_details', 'TestFc'],
                'save_callback'    => ['tl_tasting_details', 'returnNull'],
                'eval'                  => ['doNotSaveEmpty'=>true, 'tl_class'=>'w50', 'readonly' => true],
            ],
            'tasting_bottle_result' => [
                'label'                 => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_bottle_result'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            // Color
            'tasting_bottle_color' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_bottle_color'],
                'inputType' => 'text',
                'eval' => ['tl_class' => 'w50', 'maxlength' => 2, 'rgxp' => 'natural'],
                'sql' => ['type' => 'string', 'length' => 2, 'default' => '']
            ],
            // Tasting Nose
            'tasting_nose_smoke' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_nose_smoke'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_nose_fruit' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_nose_fruit'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_nose_floral' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_nose_floral'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_nose_salt' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_nose_salt'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_nose_strong' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_nose_strong'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_nose_spicy' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_nose_spicy'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_nose_woody' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_nose_woody'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_nose_medicinal' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_nose_medicinal'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_nose_malty' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_nose_malty'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_nose_notes' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_nose_notes'],
                'inputType' => 'text',
                'eval' => ['tl_class' => 'w50', 'maxlength' => 255],
                'sql' => ['type' => 'string', 'length' => 255, 'default' => '']
            ],
            //Tasting Taste
            'tasting_taste_smoke' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_taste_smoke'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_taste_fruit' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_taste_fruit'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_taste_floral' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_taste_floral'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_taste_salt' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_taste_salt'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_taste_strong' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_taste_strong'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_taste_spicy' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_taste_spicy'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_taste_woody' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_taste_woody'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_taste_medicinal' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_taste_medicinal'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_taste_malty' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_taste_malty'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_taste_notes' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_taste_notes'],
                'inputType' => 'text',
                'eval' => ['tl_class' => 'w50', 'maxlength' => 255],
                'sql' => ['type' => 'string', 'length' => 255, 'default' => '']
            ],
            // Tasting Finish
            'tasting_finish_duration' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_finish_duration'],
                'inputType' => 'select',
                'options'               => ['1', '2', '3', '4', '5'],
                'eval' => ['tl_class' => 'w10', 'maxlength' => 1, 'mandatory' => false, 'includeBlankOption' => true],
                'sql' => ['type' => 'string', 'length' => 1, 'default' => '']
            ],
            'tasting_finish_notes' => [
                'label' => &$GLOBALS['TL_LANG']['tl_tasting_details']['tasting_finish_notes'],
                'inputType' => 'text',
                'eval' => ['tl_class' => 'w50', 'maxlength' => 255],
                'sql' => ['type' => 'string', 'length' => 255, 'default' => '']
            ],
        ],
        'palettes' => [
            'default' => '{tl_tasting_details},tasting_bottle_name,tasting_bottle_name_extra,tasting_bottle_result;
                    {tasting_color}tasting_bottle_color,
                    {tl_tasting_nose},tasting_nose_smoke,tasting_nose_fruit,tasting_nose_floral,tasting_nose_salt,
                    tasting_nose_strong,tasting_nose_spicy,tasting_nose_woody,tasting_nose_medicinal,tasting_nose_malty,tasting_nose_notes;
                    {tl_tasting_taste},tasting_taste_smoke,tasting_taste_fruit,tasting_taste_floral,tasting_taste_salt,
                    tasting_taste_strong,tasting_taste_spicy,tasting_taste_woody,tasting_taste_medicinal,tasting_taste_malty,tasting_taste_notes;
                    {tl_tasting_finish},tasting_finish_duration,tasting_finish_notes'
        ],
    ];
    
    class tl_tasting_details extends Backend
    {
        
        /**
         * List a particular record
         * @param array
         * @return string
         */
        public function getBottles($arrRow)
        {
            //return array('id1' => 'Value1', 'id2' => 'Value2');
            //return $arrOptions;
            
            $db = \Contao\Database::getInstance();
            //$pid = \Contao\Input::get('pid');
            $objDBResult = $db->prepare('SELECT * FROM `tl_tasting_bottle` ORDER BY bottle_name ')
            ->execute([$pid]);
            
            $arrReturn = array();
            
            while($objDBResult->next())
            {
                $arrReturn[$objDBResult->id] = $objDBResult->bottle_name;
                
            }
            return $arrReturn;
        }
        
        public function getTastingBottles($arrRow)
        {
    
            
            $db = \Contao\Database::getInstance();
            //$pid = \Contao\Input::get('pid');
            $objDBResult = $db->prepare('SELECT bottle_name, bottler_name FROM tl_tasting_bottle 
                INNER JOIN tl_tasting_details ON tl_tasting_details.tasting_bottle_name=tl_tasting_bottle.id
                INNER JOIN tl_tasting_bottler on tl_tasting_bottler.id=tl_tasting_bottle.bottle_bottler 
                WHERE tl_tasting_bottle.id = '.$arrRow['tasting_bottle_name'])
            ->execute([$pid]);
    
            
            while($objDBResult->next())
            {
                $strBottleName = $objDBResult->bottle_name;
                $strBottlerName = $objDBResult->bottler_name;
                
            }
    
            return '<div class="tl_content_left">'.$strBottleName.' ['.$strBottlerName.']</div>';
    
        }
        
        public function returnNull($arrRow)
        {
            //return array('id1' => 'Value1', 'id2' => 'Value2');
            //return $arrOptions;
            
            
            return Null;
        }
        
        public function TestFc($arrRow)
        {
            //return array('id1' => 'Value1', 'id2' => 'Value2');
            //return $arrOptions;
            
            
            return 'test';
        }
        
    }

  4. #4
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    37.209
    Partner-ID
    10107

    Standard

    headerFields sind Felder des Parents. Du hast ein Feld des Childs angegeben (zumindest sieht es so aus, außer der Parent hat auch ein Feld mit dem selben Namen).

  5. #5
    Contao-Nutzer
    Registriert seit
    18.06.2017.
    Beiträge
    220

    Standard

    ah, das war es. Danke

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •