Search code examples
typo3typoscripttypo3-9.x

Disable sys_file_reference_field only for pages table


I have added a checkbox to sys_file_reference and utilize it to override some responsive fluid rendering. Works fine. Now I would like to disable this checkbox in the pages media field. Normally disabling fields is easily done via page typoscript

TCEFORM.TABLENAME.FIELDNAME.disabled = 1

However since the sys_file_reference is used in both pages and tt_content this won't work since it globally disables it:

TCEFORM.sys_file_reference.myfield.disabled = 1

I know I can disable fields for certain CTypes by using this syntax:

TCEFORM.tt_content.myfield.types.textmedia.disabled = 1

Is there something similar for tables instead of types? I unsuccessfully tried

TCEFORM.sys_file_reference.myfield.tables.pages.disabled = 1

TCEFORM.pages.myfield.disabled = 1

TCEFORM.pages.tables.sys_file_reference.myfield.disabled = 1

TCEFORM.pages.myfield.tables.sys_file_reference.disabled = 1

TCEFORM.pages.myfield.types.sys_file_reference.disabled = 1

Or do I need to do this in the PHP TCA Override?

thanks


Solution

  • In TCA config you can override the childs config for an specific field. So you can set the child TCA (sys_file_reference) of media for a field as type passthrough to make it hidden:

    $GLOBALS['TCA']['pages']['columns']['media']['config']['overrideChildTca']['columns']['myfield'] = [
        'config' => [
            'type' => 'passthrough'
        ]
    ];
    

    See the TCA Reference for more information.