[FLOW3-general] DateTime format in my view
John Small
flow3.tiny69 at net-con.net
Fri Dec 28 23:25:34 CET 2012
Hi,
theres a Viewhelper for that:
{some.date -> f:format.date(format:'d.m.Y H:i')}
but then you need to have a proper method in the controller who is able
to handle that format of the date to pass it to the model,
because the model expects "2012-12-28 12:33:00"
like this
public function initializeCreateAction() {
$this->addFlashMessage('here: initializeCreateAction');
// set Format for property begin
$this->arguments['newEvent']
->getPropertyMappingConfiguration()
->forProperty('begin')
->setTypeConverterOption('TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter',
\TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT,
'!d.m.Y H:i');
}
same for an update method
HTH
Am 28.12.2012 15:06, schrieb Sergio:
> Hi list,
>
> I have this in my edit view:
>
> ...
> <f:form.textfield property="break.date" id="break" />
> ...
>
> where "break" is a \DateTime property. Despite I define the break attribute
> in my model like this:
>
> /**
> * The break time
> * @var \DateTime
> * @Flow\Validate(type="NotEmpty")
> * @ORM\Column(type="time")
> */
> protected $break;
>
> and it is saved in format "12:33" in my database (because I asked for it
> when creating through Property Mapping Configuration), when the object is
> edited, it is shown again in format "2012-12-28 12:33:00".
>
> Why does this happen? And would you know a way to alter this break.date
> format and showin "12:33" format to the user in the view?
>
> Thanks in advance,
> Sergio
>
--
kind regards
More information about the FLOW3-general
mailing list