Dominique
Dominique

Reputation: 11

Typo3 9 | Extbase extension: some values are not saved from backend tca fields to database

I wrote an extbase extension for typo3 9.5.8. I started with extension builder and completed the extension manually. Now I recognize a strange behaviour. When I open an extension record for editing, the backend form is rendered well, all fields are filled correct with related datebase entries. But I can only save the values of some of the fields. Other values just get lost. If i edit these values directly in the database, they are shown correctly in the backend form. So the getter works as expected, the setter not.

Here's my setup, reduced to one field with this behaviour ("myExtension" and "myVendor" are just placeholders here, not in the real code. Didn't want my customers name to show up here):

myExtension/ext_tables.sql

#
# Table structure for table 'tx_myExtension_domain_model_kategorie'
#
CREATE TABLE tx_<myExtension>_domain_model_kategorie (
    dh_description text,
);

myExtension/Configuration/TCA/tx_myExtension_domain_model_kategorie.php

        'dh_description' => [
            'exclude' => true,
            'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_<myExtension>_domain_model_kategorie.dh_description',
            'config' => [
                'type' => 'text',
                'enableRichtext' => true,
                'richtextConfiguration' => 'minimal',
                'fieldControl' => [
                    'fullScreenRichtext' => [
                        'disabled' => false,
                    ],
                ],
                'cols' => 40,
                'rows' => 15,
                'eval' => 'trim',
            ],

        ],

myExtension/Classes/Domain/Model/Kategorie.php

namespace MyVendor\myExtension\Domain\Model;

class Kategorie extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
    /**
     * dhDescription
     *
     * @var string
     */
    protected $dhDescription = '';

    /**
     * Returns the dhDescription
     *
     * @return string $dhDescription
     */
    public function getDhDescription()
    {
        return $this->dhDescription;
    }

    /**
     * Sets the dhDescription
     *
     * @param string $dhDescription
     * @return void
     */
    public function setDhDescription($dhDescription)
    {
        $this->dhDescription = $dhDescription;
    }

I've reinstalled the extension, cleared cache, cleared typo3temp and so on. It seems, the model doesn't have any effect. If I rename the file or if I write an syntax error into it, typo3 doesn't bother.

Any ideas?

as asked, here's the complete TCA:

<?php
return [
    'ctrl' => [
        'title' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myExtension_domain_model_kategorie',
        'label' => 'kategoriename',
        'tstamp' => 'tstamp',
        'crdate' => 'crdate',
        'cruser_id' => 'cruser_id',
        'versioningWS' => true,
        'languageField' => 'sys_language_uid',
        'transOrigPointerField' => 'l10n_parent',
        'transOrigDiffSourceField' => 'l10n_diffsource',
        'delete' => 'deleted',
        'enablecolumns' => [
            'disabled' => 'hidden',
            'starttime' => 'starttime',
            'endtime' => 'endtime',
        ],
        'searchFields' => 'kategoriename,dh_description,dh_meta_keywords,dh_meta_description',
        'iconfile' => 'EXT:myExtension/Resources/Public/Icons/tx_myExtension_domain_model_kategorie.gif'
    ],
    'interface' => [
        'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, orig_id, kategoriename, ordnung, zeitstempel, in_teaser, dh_description, dh_meta_keywords, dh_meta_description, kurstypen',
    ],
    'types' => [
        '1' => ['showitem' => 'hidden, in_teaser, kategoriename, dh_description, ordnung, kurstypen,
        --div--;SEO Data, dh_meta_keywords, dh_meta_description,
        --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime,
        --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_db.xlf:tabs.seo, dh_description, dh_meta_keywords, dh_meta_description'],
    ],
    'columns' => [
        'sys_language_uid' => [
            'exclude' => true,
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectSingle',
                'special' => 'languages',
                'items' => [
                    [
                        'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages',
                        -1,
                        'flags-multiple'
                    ]
                ],
                'default' => 0,
            ],
        ],
        'l10n_parent' => [
            'displayCond' => 'FIELD:sys_language_uid:>:0',
            'exclude' => true,
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectSingle',
                'default' => 0,
                'items' => [
                    ['', 0],
                ],
                'foreign_table' => 'tx_myExtension_domain_model_kategorie',
                'foreign_table_where' => 'AND {#tx_myExtension_domain_model_kategorie}.{#pid}=###CURRENT_PID### AND {#tx_myExtension_domain_model_kategorie}.{#sys_language_uid} IN (-1,0)',
            ],
        ],
        'l10n_diffsource' => [
            'config' => [
                'type' => 'passthrough',
            ],
        ],
        't3ver_label' => [
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.versionLabel',
            'config' => [
                'type' => 'input',
                'size' => 30,
                'max' => 255,
            ],
        ],
        'hidden' => [
            'exclude' => true,
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.visible',
            'config' => [
                'type' => 'check',
                'renderType' => 'checkboxToggle',
                'items' => [
                    [
                        0 => '',
                        1 => '',
                        'invertStateDisplay' => true
                    ]
                ],
            ],
        ],
        'starttime' => [
            'exclude' => true,
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime',
            'config' => [
                'type' => 'input',
                'renderType' => 'inputDateTime',
                'eval' => 'datetime,int',
                'default' => 0,
                'behaviour' => [
                    'allowLanguageSynchronization' => true
                ]
            ],
        ],
        'endtime' => [
            'exclude' => true,
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime',
            'config' => [
                'type' => 'input',
                'renderType' => 'inputDateTime',
                'eval' => 'datetime,int',
                'default' => 0,
                'range' => [
                    'upper' => mktime(0, 0, 0, 1, 1, 2038)
                ],
                'behaviour' => [
                    'allowLanguageSynchronization' => true
                ]
            ],
        ],

        'orig_id' => [
            'exclude' => true,
            'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myExtension_domain_model_kategorie.orig_id',
            'config' => [
                'type' => 'input',
                'size' => 4,
                'eval' => 'int'
            ]
        ],
        'kategoriename' => [
            'exclude' => true,
            'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myExtension_domain_model_kategorie.kategoriename',
            'config' => [
                'type' => 'input',
                'size' => 30,
                'eval' => 'trim'
            ],
        ],
        'ordnung' => [
            'exclude' => true,
            'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myExtension_domain_model_kategorie.ordnung',
            'config' => [
                'type' => 'input',
                'size' => 4,
                'eval' => 'int'
            ]
        ],
        'zeitstempel' => [
            'exclude' => true,
            'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myExtension_domain_model_kategorie.zeitstempel',
            'config' => [
                'type' => 'input',
                'renderType' => 'inputDateTime',
                'size' => 10,
                'eval' => 'datetime',
                'default' => time()
            ],
        ],
        'in_teaser' => [
            'exclude' => true,
            'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myExtension_domain_model_kategorie.in_teaser',
            'config' => [
                'type' => 'check',
                'items' => [
                    '1' => [
                        '0' => 'LLL:EXT:lang/locallang_core.xlf:labels.enabled'
                    ]
                ],
                'default' => 0,
            ]
        ],
        'dh_description' => [
            'exclude' => true,
            'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myExtension_domain_model_kategorie.dh_description',
            'config' => [
                'type' => 'text',
                'enableRichtext' => true,
                'richtextConfiguration' => 'minimal',
                'fieldControl' => [
                    'fullScreenRichtext' => [
                        'disabled' => false,
                    ],
                ],
                'cols' => 40,
                'rows' => 15,
                'eval' => 'trim',
            ],

        ],
        'dh_meta_keywords' => [
            'exclude' => true,
            'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myExtension_domain_model_kategorie.dh_meta_keywords',
            'config' => [
                'type' => 'text',
                'cols' => 40,
                'rows' => 15,
                'eval' => 'trim'
            ]
        ],
        'dh_meta_description' => [
            'exclude' => true,
            'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myExtension_domain_model_kategorie.dh_meta_description',
            'config' => [
                'type' => 'text',
                'cols' => 40,
                'rows' => 15,
                'eval' => 'trim'
            ]
        ],
        'kurstypen' => [
            'exclude' => true,
            'label' => 'LLL:EXT:myExtension/Resources/Private/Language/locallang_db.xlf:tx_myExtension_domain_model_kategorie.kurstypen',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_myExtension_domain_model_kurstypen',
                'foreign_field' => 'kategorie',
                'maxitems' => 9999,
                'appearance' => [
                    'collapseAll' => 1,
                    'levelLinksPosition' => 'top',
                    'showSynchronizationLink' => 1,
                    'showPossibleLocalizationRecords' => 1,
                    'showAllLocalizationLink' => 1
                ],
            ],

        ],

    ],
];

Upvotes: 1

Views: 1650

Answers (1)

Dominique
Dominique

Reputation: 11

Thanks to BastianW. He brouhgt me to the right idea. Found the error.

Some fiels where presented double in 'types', so only the content of the last appereance was saved to database. :-)

Upvotes: 0

Related Questions