2012-03-19 9 views
1

選択したオプションに応じて:オプションTYPO3の、TCAフォームビュー「タイプ」を選択フィールドの値に応じて変化します私はTCAフォームバックエンドで行った

この選択フィールドは、基本的に含まれています

私がいることを、システムはその作業を行うことができます
  • RTEテキスト
  • URL

"rte text"を選択すると、 "rte text"の指定フィールドが表示されます。urlを選択すると、 "url"などの指定フィールドが表示されます。

私の場合、選択されたタイプはフィールド "タイプ"に保存されます。

私の問題は、選択したタイプに応じて、「コンテンツ」フォームフィールド/設定を変更する方法が見つからないことです。例えば

私はそれがコンテンツフィールドの設定(リッチテキストエディタ)この種の使用すべき「RTEテキスト」を選択します。

'content' => array (  
     'exclude' => 0,  
     'label' => 'Content',  
     'config' => array (
      'type' => 'text', 
      'cols' => '30', 
      'rows' => '5', 
      'wizards' => array(
       '_PADDING' => 2, 
       'RTE' => array(
        'notNewRecords' => 1, 
        'RTEonly'  => 1, 
        'type'   => 'script', 
        'title'   => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet', 
        'icon'   => 'wizard_rte2.gif', 
        'script'  => 'wizard_rte.php', 
       ), 
      ), 
     ) 
    ), 

と私は「絵」を選択すると、それはコンテンツのために使用する必要がありますがこの種の設定(ファイルアップローダ):

'content' => array (  
     'exclude' => 0,  
     'label' => 'Content',  
     'config' => array (
      'type' => 'group', 
      'internal_type' => 'file', 
      'allowed' => '',  
      'disallowed' => 'php,php3', 
      'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], 
      'uploadfolder' => 'uploads/tx_uploadshere', 
      'size' => 1,  
      'minitems' => 0, 
      'maxitems' => 1, 
     ) 
    ), 

選択ボックスの値に応じて設定を変更する方法はありますか。私は2つのコンテンツを配列に入れようとしましたが、その方法では機能しませんでした。

+0

可能です余分なビットを使って、あなたが望むものを達成することができますが、1つのテーブルフィールドに異なるコンテンツを混在させるのは間違いです。 @konsolenfreddyが提案したアプローチがより良いと思います。 – tmt

答えて

3

残念ながら、typeで1つのフィールドのプロパティを変更することはできません。

ただし、表示される内容に影響を与えることはできます。だから、2つの独立したフィールドを設定して表示を切り替えることができます

ext_tables.php

$TCA['tx_yourextension_yourtable'] = array(
    'ctrl' => array(
     //... 
     'type'=>'type', 
     //... 
    ), 
); 

TCA.php

$TCA['tx_yourextension_yourtable'] = array(
    'ctrl' => $TCA['tx_yourextension_yourtable']['ctrl'], 
    'types' => array(
     0 => array('showitem' => 'content_rte'), 
     1 => array('showitem' => 'content_image'), 
    ), 
    'columns' => array(
     'content_rte' => array(
      'exclude' => 0, 
      'label' => 'Content', 
      'config' => array(
       'type' => 'text', 
       'cols' => '30', 
       'rows' => '5', 
       'wizards' => array(
        '_PADDING' => 2, 
        'RTE' => array(
         'notNewRecords' => 1, 
         'RTEonly' => 1, 
         'type' => 'script', 
         'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet', 
         'icon' => 'wizard_rte2.gif', 
         'script' => 'wizard_rte.php', 
        ), 
       ), 
      ) 
     ), 
     'content_upload' => array(
      'exclude' => 0, 
      'label' => 'Content', 
      'config' => array(
       'type' => 'group', 
       'internal_type' => 'file', 
       'allowed' => '', 
       'disallowed' => 'php,php3', 
       'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], 
       'uploadfolder' => 'uploads/tx_uploadshere', 
       'size' => 1, 
       'minitems' => 0, 
       'maxitems' => 1, 
      ) 
     ), 
    ), 
    // ... 
); 

は(注:私は、システムを削除しました簡略化のためhidden,sys_language_uidなどのようなフィールド)

関連する問題