How to use standard fields like crdate and cruser_id with TYPO3 and extbase?
This works in TYPO3 8.7 and 9.5
model:
/**
* @var \DateTime
*/
protected $crdate = null;
/**
* Returns the creation date
*
* @return \DateTime $crdate
*/
public function getCrdate()
{
return $this->crdate;
}
TCA -> add this in the colums;
'columns' => [
'crdate' => [
'config' => [
'type' => 'passthrough',
],
],
...
]
First, the table fields are named as crdate
, and cruser
so getters should be named getCrdate
and get getCruser
Next in your model you need to add a field and a getter:
/** @var int */
protected $crdate;
/**
* Returns the crdate
*
* @return int
*/
public function getCrdate() {
return $this->crdate;
}
(do the same with cruser
field)
And finally in you setup.txt
most probably you'll need to add a mappings for these fields:
config.tx_extbase.persistence.classes {
Tx_Someext_Domain_Model_Somemodel {
mapping {
columns.crdate.mapOnProperty = crdate
columns.cruser.mapOnProperty = cruser
}
}
}
Of course, don't forget to use proper names in the settings, and clear the cache after changes in the code
This works for me with TYPO3 6.2.11
model:
/**
* tstamp
*
* @var int
*/
protected $tstamp;
/**
* @return int $tstamp
*/
public function getTstamp() {
return $this->tstamp;
}
TS:
config.tx_extbase.persistence.classes {
STUBR\Stellen\Domain\Model\Institution {
mapping {
tableName = tx_stellen_domain_model_institution
columns {
tstamp.mapOnProperty = tstamp
}
}
}
}
PS Thanks https://github.com/castiron/cicbase