Bug #27806

DateTimeConverter should return Error objects for user-errors; and support converting an empty string to NULL

Added by Michael Klapper about 4 years ago. Updated almost 4 years ago.

Status:Resolved Start date:2011-07-02
Priority:Should have Due date:
Assigned To:Sebastian Kurfuerst % Done:

100%

Category:Property
Target version:TYPO3 Flow Base Distribution - 1.0 beta 2
PHP Version: Complexity:
Has patch: Affected Flow version:

Description

Returning Error objects

The TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter should return an \TYPO3\FLOW3\Error\Error instead of throwing an \TYPO3\FLOW3\Property\Exception\TypeConverterException.

The advantage of this change is the much better handling of form convertion/validation error messages. The messages are stored as "validationResults" in $this->arguments of the current ActionController.

Displaying the messages could be easily done with the Fluid ViewHelper f:form.validationResults.

Support "empty" DateTime -> Convert to NULL

Right now, the DateTimeConverter is required, i.e. it is not possible to define an optional DateTime object.

When the DateTime converter returns NULL for the empty string, one can use "@validate NotEmpty" for required properties.

Associated revisions

Revision b47d1c61
Added by Sebastian Kurfuerst almost 4 years ago

[!!!][BUGFIX] DateTimeConverter returns Errors instead of throwing exceptions

As described in the Property Mapper reference manual, DateTimeConverter should
only throw exceptions when detecting developer failures. If user failures
happen, such as invalid input, an \TYPO3\FLOW3\Error\Error object should instead
be returned, as this is shown to the end-user in a friendly way, and the original
form is redisplayed.

Furthermore, DateTimeConverter must convert an empty date string ('') to NULL;
else it is not possible to define optional DateTime properties.

If you need a required DateTime property, use the @validate NotEmpty annotation
in your model.

Change-Id: Ie95602c44e9d86586353514cbde2cd06259f3b30
Resolves: #27806

History

#1 Updated by Robert Lemke about 4 years ago

  • Category set to Property
  • Assigned To set to Sebastian Kurfuerst
  • Target version set to 1230

#2 Updated by Sebastian Kurfuerst almost 4 years ago

  • Status changed from New to Accepted
  • Target version changed from 1230 to 1.0 beta 2

#3 Updated by Sebastian Kurfuerst almost 4 years ago

  • Subject changed from DateTimeConverter should return an Error instead of throwing Exceptions to DateTimeConverter should return Error objects for user-errors; and support converting an empty string to NULL

Hey Michael,

sorry for hijacking the description; I extended it a bit - and will work on a fix now.

Greets,
Sebastian

#4 Updated by Mr. Hudson almost 4 years ago

  • Status changed from Accepted to Under Review

Patch set 1 of change Ie95602c44e9d86586353514cbde2cd06259f3b30 has been pushed to the review server.
It is available at http://review.typo3.org/4786

#5 Updated by Mr. Hudson almost 4 years ago

Patch set 2 of change Ie95602c44e9d86586353514cbde2cd06259f3b30 has been pushed to the review server.
It is available at http://review.typo3.org/4786

#6 Updated by Sebastian Kurfuerst almost 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF