typo3 extbase:如何在CommandController中定义其他值

时间:2015-12-03 14:03:26

标签: php extbase

我在其中一个扩展中创建了一个新的CommandController,我现在需要做的是添加一个额外的字段,后端用户可以插入一些可以在CommandController内使用的数据。

我尝试谷歌这个,我发现的是关于additionalFieldsfieldProdiver的内容,但我发现没有任何与extbase CommandController功能相关的内容。

我非常感谢有关如何实现这一目标的任何提示。

1 个答案:

答案 0 :(得分:0)

意味着" additionalFields"如果我收到您的问题,那么您需要更多字段才能从后端管理员处获取更多信息。

在extBase中:

第1步:将字段添加到扩展程序sql文件中 添加位于

中的ext_tables.sql文件中的字段
  

YOUR_EXTENSION / ext_tables.sql

CREATE TABLE tx_YOUREXTENSION_domain_model_TABLENAME (
   /**your existing fields... **/
   newfield varchar(255) DEFAULT '' NOT NULL, // add new
);

第2步:在安装工具中比较数据库和更新
转到后端>安装工具> "将当前数据库与规范进行比较" 并更新它。

第3步: TCA

  

YOUR_EXTENSION /配置/ TCA / Command.php

数组中添加您的字段名称
1. "showRecordFieldList" => "newfield"
2. "showitem" => "newfield"

现在你需要配置你的字段:

'newfield' => array(
    'exclude' => 1,
    'label' => 'YOUR_LABLE',
    'config' => array(
        'type' => 'input',
        'size' => 30,
        'eval' => 'trim'
    ),
),

有关更多字段配置,请参阅TCA Reference

第4步:模型[get set method]

  

YOUR_EXTENSION /类别/域/型号/ Command.php

/**
 * newfield
 *
 * @var string
 */
protected $newfield = '';

/**
 * Returns the newfield
 *
 * @return string $newfield
 */
public function getNewfield() {
    return $this->newfield;
}

/**
 * Sets the newfield
 *
 * @param string $newfield
 * @return void
 */
public function setNewfield($newfield) {
    $this->newfield= $newfield;
}

第5步:清除缓存
最后也是最重要的;)清除安装工具缓存