簡體   English   中英

TYPO3 9 LTC類型轉換錯誤在TCA類型輸入/ dbType節省時間的空字段的mysql時間字段上

[英]TYPO3 9 LTS type casting error on mysql time field for TCA type input / dbType time saving empty field

我正在嘗試在TYPO3 9 LTS中與MySQL 5.7.24一起使用的時間輸入。

ext_tables.sql該字段的定義如下:

some_field time default NULL

在TCA中,該字段的定義如下:

  'some_field' => [
    'exclude' => 1,
    'label' => 'Some field',
    'config' => [
      'type' => 'input',
      'dbType' => 'time',
      'eval' => 'time',
    ],
  ],

當在沒有時間輸入的情況下將記錄保存在后端時(應該是可能的),我得到了錯誤:

These fields of record 1 in table "some_table" have not been saved correctly: some_field! The values might have changed due to type casting of the database.

查看數據庫記錄時, some_field字段的值為00:00:00 (盡管db的默認值為NULL )。

選擇時間時,可以保存並打開記錄而不會出現錯誤。

這是TYPO3中的錯誤,還是我該如何解決此問題?

這意味着您為ext_tables.sql中的值輸入了錯誤的類型。 此外,TYPO3 v9具有renderTypes 嘗試這樣的事情:

ext_tables.sql

begin int(11) DEFAULT '0' NOT NULL

三氯乙酸

'begin' => [
   'exclude' => true,
   'label' => 'LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tx_yourext_domain_model_modelname.begin',
   'config' => [
        'type' => 'input',
        'renderType' => 'inputDateTime',
         'size' => 10,
         'eval' => 'datetime',
         'default' => time()
     ],
],

附加信息!

如果要在FrontEnd中顯示時間,可以使用類似的方法

<f:format.date>{dateObject.begin}</f:format.date>

如果要修改外觀,還可以使用format屬性:

<f:format.date format="%d. %B %Y">{dateObject.begin}</f:format.date>

有關此內容的更多信息: TYPO3日期格式

該錯誤可以通過以下eval來解決:

'eval' => 'time,null',

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM