【问题标题】:typo3 extbase: how to define additional values in CommandController错字3 extbase:如何在 CommandController 中定义附加值
【发布时间】:2015-12-03 14:03:25
【问题描述】:

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

我试图用谷歌搜索这个,我发现了一些关于 additionalFieldsfieldProdiver 的东西,但我没有找到与 extbase CommandController 功能相关的东西。

对于如何实现这一点的任何提示,我将不胜感激。

【问题讨论】:

标签: php extbase


【解决方案1】:

“附加字段”的意思如果我收到您的问题,那么您需要更多字段才能从后端管理员那里获取更多信息。

在 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/Configuration/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

第四步:模型[get set方法]

YOUR_EXTENSION/Classes/Domain/Model/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 步:清除缓存
最后也是最重要的 ;) 清除安装工具缓存

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多