philomine
philomine

Reputation: 51

Creating Datetime Column in Database using TCA file

In my Typo3 extension ,I want one of my table column as 'datetime' with type as'timestamp' and default as 'CURRENT_TIMESTAMP'. How can I create this in TCA file.

I have given my code below. But this is not creating the column with type timespamp and default value as CURRENT_TIMESTAMP.

     'datetime' => array(       
        'exclude' => 0,     
        'label' => 'LLL:EXT:besi_jobs/locallang_db.xml:tx_jobs_messages.datetime',      
        'config' => array(
            'type'     => 'timestamp',
            'size'     => '12',
            'max'      => '20',
            'eval'     => 'datetime',
            'checkbox' => '0',
            'default'  => 'CURRENT_TIMESTAMP'

        )
    ),

Upvotes: 0

Views: 2422

Answers (1)

tmt
tmt

Reputation: 8614

The type must be set to 'input':

'datetime' => array(        
    'exclude' => 0,     
    'label' => 'LLL:EXT:besi_jobs/locallang_db.xml:tx_jobs_messages.datetime',      
    'config' => array(
        'type'     => 'input',
        'size'     => '12',
        'max'      => '20',
        'eval'     => 'datetime',
        'checkbox' => '0',
        'default'  => time(),
    )
),

NOTES

  • All the possible types are described in the TCA reference.
  • The field in the .sql file file of your extension should be int(11) unsigned NOT NULL DEFAULT '0'. The TCA definition neither creates nor alters the database. It only defines how the field is displayed in the forms.

Upvotes: 2

Related Questions