我创建了一个extbase模型,并尝试在创建新项目时设置sys_language_uid字段。但由于某种原因,它完全被忽略并始终设置为0,即使我尝试输入的值肯定是1.
我的模型看起来像这样:
class Ad extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
/**
* sysLanguageUid
*
* @var integer
*/
protected $sysLanguageUid;
/**
* @return int
*/
public function getSysLanguageUid()
{
return $this->sysLanguageUid;
}
/**
* @param int $sysLanguageUid
*/
public function setSysLanguageUid($sysLanguageUid)
{
$this->sysLanguageUid = $sysLanguageUid;
}
// ... etc.
}
在我的控制器中,我尝试做的就是:
$ad = new Ad();
$ad->setSysLanguageUid($GLOBALS['TSFE']->sys_language_uid);
$ad->setSomeOtherParam('xxx');
$this->adRepository->add($ad);
另一个参数保存得很好。 sys_language_uid存在于ext_tables.sql和TCA中:
'columns' => array(
'sys_language_uid' => array(
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.language',
'config' => array(
'type' => 'select',
'foreign_table' => 'sys_language',
'foreign_table_where' => 'ORDER BY sys_language.title',
'items' => array(
array('LLL:EXT:lang/locallang_general.xml:LGL.allLanguages', -1),
array('LLL:EXT:lang/locallang_general.xml:LGL.default_value', 0)
),
),
),
'some_other_field' => ....
)
为什么setSysLanguageUid不起作用?任何提示?
答案 0 :(得分:6)
/**
* _languageUid
* @var int
*/
protected $_languageUid;
/**
* @param int $_languageUid
* @return void
*/
public function set_languageUid($_languageUid) {
$this->_languageUid = $_languageUid;
}
/**
* @return int
*/
public function get_languageUid() {
return $this->_languageUid;
}
我发誓,错字3会让我心脏病发作一天......