【发布时间】:2013-08-07 08:32:47
【问题描述】:
我有一个这样定义的字段:
max_items int(11) NULL
如果您在后端将此字段留空,我希望它存储 NULL。
为此,我在 TCA 中使用此配置,但不起作用:
'max_items' => array(
'exclude' => 0,
'label' => '...',
'config' => array(
'type' => 'input',
'eval' => 'null',
),
),
编辑:
它不存储预期值NULL,而是存储0。
我试过max_items int(11) DEFAULT NULL,但还是不行。
编辑2: 谢谢新鲜! 我最终编写了自己的 eval 函数:
<?php
class tx_myextension_evalfunc {
function evaluateFieldValue($sValue, $aIsIn, &$bSet)
{
return ($sValue === '') ? null : $sValue;
}
}
?>
使用此配置:
'max_items' => array(
'exclude' => 0,
'label' => '...',
'config' => array(
'type' => 'input',
'eval' => 'tx_myextension_evalfunc',
),
),
【问题讨论】:
-
对不起,“但它不起作用”不是很有帮助。你有错误吗?数据库中实际存储了什么?这是您领域的全部配置还是您遗漏了什么?
-
您应该在数据库字段中使用“max_items int(11) DEFAULT NULL”。
-
感谢 cmets,我编辑了问题。
-
你问题的第二部分是问题的一部分还是答案?
标签: typo3 extbase typo3-6.1.x