Issue Bug Closed

#76701Not possible to insert NULL value with TCA type 'select'

Viktor Livakivskyi 06/20/16, 11:23 updated 02/06/26, 10:58

Description

Hi,

I want a possibility to insert NULL via BE into a field of type “select”.

My TCA definition is follwoing:

'industry' => [
    'exclude' => 0,
    'label' => 'LLL:EXT:my_ext/Resources/Private/Language/locallang_db.xlf:fe_users.industry',
    'config' => [
        'type' => 'select',
        'renderType' => 'selectSingle',
        'foreign_table' => 'tx_myext_domain_model_industry',
        'minitems' => 0,
        'items' => [
            ['', null],
        ]
    ]
],

ext_tables.sql:
@industry int(11) unsigned default NULL,@

The problem is, that whenever an empty value from “industry” is sent to a server it is translated into following query:
@UPDATE fe_users SET industry=’‘,tstamp=‘1465920150’ WHERE uid=2;@
And due to disabled “strict mode” it translates to 0 by MySQL.

Also tried to set ‘-1’ as drop-down option value, but result is the same.

I guess, it should be some fields processor, which explicitly sets NULL for fields, which desire it.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.