Reputation: 3504
I see that there's a 'last changed'-property in my table created with the extension builder called 'tstamp' but I can't figure out how to display it in the front-end.
In the front-end I'm using fluid like this, but it stays empty:
<f:format.date format="d.m.Y - H:i">{appointment.tstamp}</f:format.date>
I can see the property in the TCA also:
'ctrl' => array(
'title' => 'LLL:EXT:extTest/Resources/Private/Language/locallang_db.xlf:tx_extTest_domain_model_appointment',
'label' => 'start_date',
'tstamp' => 'tstamp',
I tried adding this in my php class file but it didn't change anything
/**
* @var DateTime
*/
protected $tstamp;
/**
* Get Tstamp
*
* @return DateTime
*/
public function getTstamp() {
return $this->tstamp;
}
I think the problem is that I don't understand the connection from the TCA to the PHP Class, can someone help?
Upvotes: 1
Views: 1330
Reputation: 7939
The issue is that you also need a TCA configuration for every field as extbase gets there required information (especially for relations). Therefore add something like this into the TCA of your table:
'tstamp' => [
'label' => 'tstamp',
'config' => [
'type' => 'passthrough',
]
],
You don't need to add the field to a actual type.
The annotation in the model should be
/**
* @var \DateTime
*/
protected $tstamp;
So don't forget the \
before the DateTime.
Clear caches and you are fine
Upvotes: 3