contao/test — Issue #2890: Add csv storage support for multiple-type fields
Author: importer
Created: 2011-11-29 10:30:35+00:00
State: open
Labels: Feature, framework

I often use multiple=>true fields, but instead of storing their values as serialised, I store them as comma-separated (csv) as follows:

$varValue = '1,64,44,23'; // 4 ids are selected and stored.

To achieve this of course I have a load_callback and save_callback.

However, when using this method, the default Contao Filter system doesn't work. I have added a new variable called:

```

// Manual filter
elseif ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['multiple'])
{
if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$field]['eval']['csv'])
{
$this->procedure[] = 'FIND_IN_SET(?, '. $field . ')';
$this->values[] = $session['filter'][$filter][$field];
}
else
{
$this->procedure[] = $field . ' LIKE ?';
$this->values[] = '%"' . $session['filter'][$filter][$field] . '"%';
}
}
```

and where the options are extracted and intersected with all the options:

```