As I’ve mentioned earlier, the FLOW3 documentation is a bit weak at the moment. The initial example walks you through a very simple view where only strings (like “title”, “author”) are entered via the view’s form. But how do you enter a date and have it converted to a “real” \DateTime upon initializing the object that should contain it?
I found the solution (again, mainly by chance) here: How to use the DateTimeConverter in FLOW3. Apparently, you have to convert the user’s input to the needed objects in a method in the corresponding controller, that is (magically?) called before the method that expects the main object you want to create (that contains the date).
Here’s an example: If you have a Report object that has a dueDate attribute of type \DateTime, you have to convert the user input (a string) to a \DateTime object in the method initializeCreateAction() of class ReportController.
FLOW3 offers quite a few type converters, among which you can also find a DateTimeConverter. You can use it like this in initializeCreateAction():
public function createAction(Report $report) { ... }
public function initializeCreateAction() {
$this->arguments['report']
->getPropertyMappingConfiguration()
->forProperty('dueDate')
->setTypeConverterOption(
'TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter',
\TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT,
'Y-m-d');
}
FLOW3 now converts the input string (format ‘Y-m-d’) into a “real” \DateTime object before passing it on to the newly created Report object, that gets passed to createAction().
Vielen Dank, genau das habe ich gesucht mit dem Datum! Klappt prima!