typo3 - TCA foreign_table 如何为 select:options 选择标签
问题描述
$temporaryColumns = array(
'my_related_item' => array(
'label' => 'Related s',
'l10n_mode' => 'mergeIfNotBlank',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'items' => [
],
'foreign_table' => 'tx_some_domain_model_item',
'MM' => 'tx_some_domain_model_mm',
'itemsProcFunc' => 'my\ext\TCA\SelectProcFunc->prepareItems',
'enableMultiSelectFilterTextfield' => true,
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
],
),
);
应该是从我想用作标签的目标实体提交的可能选项。但是在文档中找不到这个。
例如 - 默认情况下我进入选择框:选项
{value = uid
label = title }
但是我需要
{value = uid
label = clear_name}
更新:
我发现要在我无法使用的 selctbox 中获取自定义标签
'ctrl' => [
'label' => 'clear_name',
],
因为这将在全球范围内更改列表-但我只需要在选择框中。所以我在我的 TCA 中尝试了其他解决方案
'itemsProcFunc' => 'TBF\TbfPackage\TCA\SelectProcFunc->prepareItems',
并在 SelectProcFunc.php
namespace my\ext\TCA;
/**
* Description of SelectProcFunc
*
* @author Oleg Karun
*/
class SelectProcFunc {
public function prepareItems(&$param) {
debug($param);
$newItems = [];
foreach ($param['items'] as $item) {
$newItem = [
0 => $item->getUid(),
1 => $item->getClearName()
];
$newItems[] = $newItem;
}
//$param['items'] = $newItems;
return $param;
}
}
问题我的 $param['items'] 为空 - 我发现同样的问题https://forge.typo3.org/issues/85622。错误还是我做错了什么?
解决方案
因为foreign_table
它总是label
用于呈现可用项目列表的外表。因此,如果您想要一个不同的字段,您将需要更改该选项。
推荐阅读
- postgresql - 遵循使用 dnf 的官方说明后,我无法在 Red Hat 8.1 上安装 PostgreSQL 12
- wordpress - 根据时间戳自定义日期显示 wordpress 每日帖子
- javascript - Vuex:将存储状态擦除回空数组
- linux - 如何在 bash.sh 脚本中创建和在屏幕之间移动
- performance - 向量化乘以不同的常数
- mysql - 如何在 PopSQL 应用程序中使用 DELIMITER 语句?
- amazon-web-services - 如何使用浏览器从 s3 存储桶下载数据?
- javascript - 如何使用 Chrome 添加EventListener 来监听推送通知
- arrays - 将项目列表分块成对列表的操作的名称,其中每对的第二项形成下一个的第一项?
- wordpress - 当客户在 WooCommerce 中购买产品时,在最终结帐页面上获取订单 ID