[TYPO3-dev] TCA record type based on foreign record field

Peter Bücker news.naag at gmx.net
Mon Jan 31 13:08:38 CET 2011


Hi all,

in an extension, I've defined a table "tx_myext_table" with a record
type field (...['ctrl']['type']). This field is rendered as a select
field and gets it's values from a foreign table ("tx_myext_table2"):

'type' => array(
  'exclude' => 1,
  'label' => 'LLL:EXT:myext/locallang_db.xml:tx_myext_table.type',
  'config' => array(
    'type' => 'select',
    'foreign_table' => 'tx_myext_table2',
    'size' => 1,
    'minitems' => 1,
    'maxitems' => 1,
  )
)

tx_myext_table2 has two columns, "uid" and "type", which is a varchar.
So what's actually displayed to the user as values of the type field are
all records from tx_myext_table2. My ['types']-section currently looks
like this:

'types' => array(
  '1' => array('showitem' => 'field1,field2'),
  '2' => array('showitem' => 'field3,field4'),
  '3' => array('showitem' => 'field5,field6')
)

Can I somehow use tx_myext_table2.type as a key here, instead of
tx_myext_table2.uid? However I'd still like to have the UID saved in
tx_myext_table.type. So the user selects a value from the select box,
e.g. "Advertisement", the TCA-configuration is switched because
"Advertisement" is a key in ['types']. The user saves the record and the
UID of the tx_myext_table2 record with type = "Advertisement" is saved
into the database.

Is there any way to do this, or is it impossible with the current
implementation of record type fields? I'm open for all kinds of suggestions!

Thanks for your help.

Regards,
Peter




More information about the TYPO3-dev mailing list