Bug #69650
closedDomain Model with one optional DateTime validator
0%
Description
Hey
I'm not sure if it's a bug but:
I have Domain model with some properties. One of the property has annotation
/**
* start
*
* @var \DateTime
* @validate DateTime(d.m.Y)
*/
protected $start = NULL;
other properties are without any validation. When I create form with property="start" and I leave input blank I'm getting following error:
#1: PHP Warning: Illegal offset type in isset or empty in .../typo3/sysext/extbase/Classes/Error/Result.php line 214
When i insert something to input I got proper error action with validation results.
When I add to model other validation i.e.:
/**
* title
*
* @var string
* @validate NotEmpty
*/
protected $title = '';
And I fill title input and leave start input blank I got proper error action with validation results. (that means I got validation error on start that start input was empty)
Is it bug or I'm doing something wrong
Thank you
Updated by Stephan Großberndt almost 9 years ago
- Status changed from New to Closed
- Priority changed from Must have to -- undefined --
This is not a bug.
/** * @var \DateTime * @validate NotEmpty */
is sufficient. This makes sure the object contains a \DateTime object and its not empty.
Your use of DateTime(d.m.Y)
implies you want to test (or maybe have even stored your data?) against a formatted string. \DateTime properties have to be saved as int (Unix-Timestamp) or as mysql native DATETIME (which has some timezone related bugs currently IIRC).
If you think this is a wrong decision to close this issue, please answer here.
Updated by Stephan Großberndt almost 9 years ago
For further support/questions please join us on Slack https://forger.typo3.org/slack and ask in the #typo3-cms channel.