TYPO3 FlexForm: how to disable field in inline element?

1.4k Views Asked by At

I have a TYPO3 plugin with a FlexForm. In the FlexForm I added relations to a foreign table. I now need to disable some of the fields of the foreign table. I can't do this via user rights since it's a question of context, not rights.

My FlexForm looks like this:

<settings.moreinfo>
    <TCEforms>
        <label>my label</label>
        <config>
            <type>inline</type>
            <foreign_table>tx_foo_domain_model_bar</foreign_table>
            <foreign_field>content_uid</foreign_field>
            <foreign_sortby>sorting</foreign_sortby>
            <maxitems>50</maxitems>
        </config>
    </TCEforms>
</settings.moreinfo>

I thought about TCEFORM, but have no idea how to address the field:

TCEFORM.tt_content.pi_flexform.foobar.general {
  settings\.moreinfo {
    # maybe here?
  }
}

Is there any possibility to disable a field via TSconfig or PHP?

2

There are 2 best solutions below

0
On BEST ANSWER

This answer to a different question inspired me to the solution which finally solved my problem!

foreign_types was the solution I was looking for:

<settings.moreinfo>
    <TCEforms>
        <label>my label</label>
        <config>
            <type>inline</type>
            <foreign_table>tx_foo_domain_model_bar</foreign_table>
            <foreign_field>content_uid</foreign_field>
            <foreign_sortby>sorting</foreign_sortby>
            <maxitems>50</maxitems>
            <foreign_types type="array">
                <numIndex index="1" type="array">
                    <showitem>
                        title, link, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access, hidden;;1, starttime, endtime
                    </showitem>
                </numIndex>
            </foreign_types>
        </config>
    </TCEforms>
</settings.moreinfo>
1
On

in general you could disable flexform fields. the manual states the possibility:

Other properties also apply to flex form fields, in this case the full property path including the data structure key has to be set:
TCEFORM.[tableName].[fieldName].[dataStructureKey].[flexSheet].[flexFieldName].[propertyName].
The [dataStructKey] represents the key of a FlexForm in $GLOBALS['TCA'][<tableName>]['columns'][<field>]['config']['ds']. This key will be split into up to two parts. By default the first part will be used as identifier of the FlexForm in TSconfig. The second part will override the identifier if it is not empty, list or *.
For example the identifier of the key my_ext_pi1,list will be my_ext_pi1 and of the key *,my_CType it will be my_CType. See section Pointing to a data structure of the TCA reference for details.

Some properties apply to whole FlexForm sheets, their property path is TCEFORM.[tableName].[fieldName].[dataStructureKey].[flexSheet].[propertyName].

it could be problematic if you use . inside of identifiers.