5

I have made an extension in Typo3 4.5 with extbase and fluid. Now to insert some data i use the backend module 'list' that makes some forms with the TCA of the tables. To make a select box optional, I insert an item before the foreign table like this:

    'feuser' => array(
        'exclude' => 0,
        'label' => 'LLL:EXT:yes/Resources/Private/Language/locallang_db.xml:tx_yes_domain_model_schools.feuser',
        'config' => array(
            'type' => 'select',
            'items' => array(
                array('', NULL),
            ),
            'foreign_table' => 'fe_users',
            'maxitems' => 1,
        ),
    ),

Now, since i have a relation (with NULL alowed) in my DB, i have to insert a NULL value. But like this it doesn't work. I have also tried '', "" and 0. But those don't work either.

I would appreciate any help.

Agash Thamo.
  • 748
  • 6
  • 18

1 Answers1

5

Try this:

'items' => array(
    array('', -1))

The second parameter in the array is not the value for the db!

Wipster
  • 1,510
  • 1
  • 15
  • 32
  • 1
    **update:** `'items' => [['label', value, 'icon(optional)']]` - [TCA Reference](https://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Select/Index.html#items) I used 0 as value and the default to 0 ... – webman Dec 13 '16 at 11:29
  • do you know, how to store null in the db, if the option with -1 was selected? – olek07 Aug 02 '23 at 17:42