I created the entity Appointment
in my extension builder.
Each Appointment
is happening on a certain day and has a start time and an end time.
It never goes beyond a day so I only need one date.
That's why I added those 3 properties to my model in the extension builder:
When creating a new appointment in the frontend I now know how to deal with the date format but no idea how to convert the time to the fitting Integer as the extension builder set it in my model.
When trying to create a new appointment I get this error:
An error occurred while trying to call vendor\extname\Controller\AppointmentController->createAction()
newAppointment.startTime: "09:35" is no integer. The given subject was NULL. newAppointment.endTime: "10:35" is no integer.
In my controller I have this function which works for the Date:
public function initializeAction() {
if ($this->arguments->hasArgument('newAppointment')) {
$this->arguments->getArgument('newAppointment')->getPropertyMappingConfiguration()->forProperty('startDate')->setTypeConverterOption('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter',\TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT,'d.m.Y');
}
}
I tried adding:
$this->arguments->getArgument('newAppointment')->getPropertyMappingConfiguration()->forProperty('startTime')->setTypeConverterOption('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\IntegerConverter',\TYPO3\CMS\Extbase\Property\TypeConverter\IntegerConverter);
but that was a fail as it says:
Fatal error: Undefined constant 'TYPO3\CMS\Extbase\Property\TypeConverter\IntegerConverter' in ...AppointmentController...
I even checked that path and the IntegerConverter is there...
Not sure if I'm supposed to use it in this case or if there's some other simple way to do this...?
And also once this works, how would I display it - currently for the date I'm doing:
{appointment.startDate->f:format.date(format:'d.m.Y')}
but will I be able to do this with my Time Integer?:
{appointment.startTime->f:format.date(format:'H:i')}
startTime
in your model toDateTime
or\DateTime
? Be sure to clear the caches from the install tool after the change. – Jost