Search code examples
typo3typo3-11.x

TYPO3 TCE modify onChange in THEFORM


I have a field (let's call is select1) which is used in twoContent Elements. In one of the Content Element it needs to reloads the TCE Form because some fields only need to be shown if select1 has a certain value selected.

This works fine as I'm using the following TCE:

TCE for the select1 field:

        'exclude' => 1,
        'label' => 'foo',
        'onChange' => 'reload',
        'config' => [
            'type' => 'select',
            'renderType' => 'selectSingle',
            'default' => 1,
            'items' => [
                [
                    'foo1',
                    1,
                ],
                [
                    'foo2',
                    2,
                ],

            ],
        ],

Now the challenge is, that I'm using the same field (select1) in another content element and there I don't need the reload onChange.

I've tried to change the value of the onChange within TCEFORM (I've tried it eventhough its the only field that you apparently cant modify through TCE, according to the TCE Docs)

TCEFORM {
    tt_content {
        select1{
            types {
                mySecondContentElement{
                    onChange = ''
                }
            }
        }
    }
}

Is there a way to disable the onChange for a ceratin Content Element?

I could create a new Field in the Database, but this seems wrong to me.

I'm using TYPO3 LTS 11.

Thanks for the help!


Solution

  • Using TsConfig only some specific columns can be overriden and not all but you can use the feature columnsOverrides which is described here

    So that could look like that

    $GLOBALS['TCA']['tt_content']['types']['your-ce-type']['columnsOverrides']['select1']['onChange'] = 'reload'