Search code examples
formstypesloadtypo3tx-news

Typo3 6.0 - load form fields depending on type of News 2.1


I am new to Typo3, I'm using version 6.0. I have made a custom extension extending from News 2.1, and I made some custom fields and created a new type of news called "Activity". What I want to do is that when you choose "Activity" from the select type, the form reloads with the custom fields I want.

In other words, I want to reproduce what happens when you change the type of new from "News" to "Internal page" for example, but with the fields I want like in this : (in ext_tables.php)

$tmp_activite_columns = array(

'act_field1' => array(
    'exclude' => 0,
    'label' => 'LLL:EXT:myExt/Resources/Private/Language/locallang_db.xlf:myExt.act_field1',
    'config' => array(
        'type' => 'input',
        'size' => 30,
        'eval' => 'trim'
    ),
),
'act_axe' => array(
    'exclude' => 0,
    'label' => 'LLL:EXT:myExt/Resources/Private/Language/locallang_db.xlf:myExt.act_axe',
    'config' => array(
        'type' => 'input',
        'size' => 30,
        'eval' => 'trim'
    ),
),
);

How can I use $tmp_activite_columns so the form loads with these fields ?


Solution

  • You have to add this columns permanently to your TCA. Via TCA, you can then define a displayCond (display condition) to fields you only want to display, if another field has a certain value.

    I assume your form already reloads when you choose the type, so here is an example for the displayCond in the TCA:

    'act_field1' => array(
      'displayCond' => 'FIELD:type:=:3',
      'exclude' => 0,
      'label' => 'LLL:EXT:myExt/Resources/Private/Language/locallang_db.xlf:myExt.act_field1',
      'config' => array(
        'type' => 'input',
        'size' => 30,
        'eval' => 'trim'
       ),
    ),
    

    So basically you check if the field "type" has the value "3" for example. You can find more information about displayCond in the TCA Documentation.