Typo3 TCA select中自定义列的值
我在Typo3 TCA中创建了一个select,它看起来如下所示:Typo3 TCA select中自定义列的值,typo3,extbase,Typo3,Extbase,我在Typo3 TCA中创建了一个select,它看起来如下所示: 'company_address' => array( 'exclude' => 1, 'label' => 'Company Address', 'config' => array( 'type' => 'select', 'foreign_table' => 'pages', 'foreign_table_where' => ' A
'company_address' => array(
'exclude' => 1,
'label' => 'Company Address',
'config' => array(
'type' => 'select',
'foreign_table' => 'pages',
'foreign_table_where' => ' AND doktype = 75',
'items' => array(
array('', 0)
),
'maxitems' => 1
)
),
默认值=记录的uid,如何更改
我需要这个值=我的_列。有可能吗?您可以使用itemProcFunc按需要构建选择选项。在TCA中,您可以更改配置:
'company_address' => array(
'config' => array(
'type' => 'select',
'itemsProcFunc' => 'Vendor\\MyExt\\UserFunc\\TcaProcFunc->companyAddressItems'
'maxitems' => 1
)
)
然后可以实现自定义函数。我给你举个例子
namespace Vendor\MyExt\UserFunc;
class TcaProcFunc
{
/**
* @param array $config
* @return array
*/
public function companyAddressItems($config)
{
$itemList = [];
$rows = $this->getMySpecialDokTypeRowsFromDb();
foreach ($rows as $row) {
$itemList[] = ['Label of the item', $row['my_column']];
}
$config['items'] = $itemList;
return $config;
}
}
无论您在
$config['items']
中存储什么,都将是选择框中的项目列表。为了使这个(未经测试的)示例起作用,您当然要实现方法getMySpecialDokTypeRowsFromDb()
您可以使用itemProcFunc按需要构建选择选项。在TCA中,您可以更改配置:
'company_address' => array(
'config' => array(
'type' => 'select',
'itemsProcFunc' => 'Vendor\\MyExt\\UserFunc\\TcaProcFunc->companyAddressItems'
'maxitems' => 1
)
)
然后可以实现自定义函数。我给你举个例子
namespace Vendor\MyExt\UserFunc;
class TcaProcFunc
{
/**
* @param array $config
* @return array
*/
public function companyAddressItems($config)
{
$itemList = [];
$rows = $this->getMySpecialDokTypeRowsFromDb();
foreach ($rows as $row) {
$itemList[] = ['Label of the item', $row['my_column']];
}
$config['items'] = $itemList;
return $config;
}
}
无论您在
$config['items']
中存储什么,都将是选择框中的项目列表。为了使这个(未经测试的)示例起作用,您当然要实现方法getMySpecialDokTypeRowsFromDb()
谢谢你的回答。我创建了一个非常类似的东西,它可以工作:)我很失望,因为我认为有更简单的方法,在配置数组中有一些特殊的关键字,也许将来他们会添加它:)谢谢你的回答。我创建了一个非常类似的东西,它可以工作:)我很失望,因为我认为有更简单的方法,在配置数组中有一些特殊的关键字,也许将来他们会添加它:)