contao/import — Issue #3277: eval->required does not work as expected
Author: Toflar
Created: 2011-11-29 21:16:08+00:00
State: open
Labels: backend, Defect

Hi Leo

While debugging the Catalog I discovered a bug in DataContainer.php on line 226 (trunk):

```
$arrData['eval']['required'] = ($this->varValue == '' && $arrData['eval']['mandatory']) ? true : false;
```

You check for an empty string to determine whether there has been data entered or not.
Unfortunately this leads to a strange behaviour when the following field characteristics are given:

* the definition of the field is not a string, e.g. "int(10) NOT NULL default '0'"
* the field is set to mandatory
* the field has no default value

Then the user doesn't get any asterisk sign because the default value is 0 instead of ''.

Unfortunately I couldn't find any case where this happens in the core for you to reproduce the issue because whenever you have a field with the definition "int(10) NOT NULL default '0'", you provide a default value so $this->varValue in the DataContainer.php is not empty and obviously this is correct because a value is already chosen even if it hasn't been done by the user.

Do you see the problem? =)

[Download the attachments](http://www.contao.org/tl_files/tickets/3277.zip "Download the attachments of this ticket")
Related issues: #3356

--- _Originally created on July 18th, 2011, at 02:00pm (ID 3277)_