[FLOW3-general] DateTime format in my view
Sergio
naguib.mahfuz at gmail.com
Thu Jan 3 13:04:08 CET 2013
I finally got it, David! :)
If it useful for anybody: "property" in <f:form.textfield> overwrites
"value" and "name". But you can overwrite "value" too. The problem I had is
I should have used the entire object for overwritting the format date in
the inline notation, not only the property like I used in the "property"
field. I mean:
<f:form.textfield property="break.date" id="start" class="two timepicker"
value="{workingDay.break.date -> f:format.date(format:'H:i')}" />
where {workingDay} is my main object.
2013/1/3 Sergio <naguib.mahfuz at gmail.com>
> That's it. If I change it the way you say, the input field is empty. If I
> don't use a "value" property for the form.textfield, the date is shown in
> the wrong format.
>
>
> 2013/1/3 David Sporer <david.sporer at gmail.com>
>
> > But you have changed the format that should be displayed in the view
> helper
> > right?
> > <f:form.textfield property="break.date" id="break" value="{break.date ->
> > f:format.date(format:'H:i')}" />
> >
> > -----Ursprüngliche Nachricht-----
> > Von: flow3-general-bounces at lists.typo3.org
> > [mailto:flow3-general-bounces at lists.typo3.org] Im Auftrag von Sergio
> > Gesendet: Donnerstag, 3. Januar 2013 11:20
> > An: General discussion about FLOW3
> > Betreff: Re: [FLOW3-general] DateTime format in my view
> >
> > No, it's right. "break.date" is shown inside the input field but with the
> > wrong format, eg "2013-01-03 00:10:00".
> >
> >
> > 2013/1/3 David Sporer <david.sporer at gmail.com>
> >
> > > Could it be that just break.date is wrong?
> > > Is it perhaps workingDay.break or something else?
> > >
> > > -----Ursprüngliche Nachricht-----
> > > Von: flow3-general-bounces at lists.typo3.org
> > > [mailto:flow3-general-bounces at lists.typo3.org] Im Auftrag von Sergio
> > > Gesendet: Donnerstag, 3. Januar 2013 10:57
> > > An: General discussion about FLOW3
> > > Betreff: Re: [FLOW3-general] DateTime format in my view
> > >
> > > Well, I don't receive an error. The input element value is just empty.
> > >
> > >
> > > 2013/1/3 David Sporer <david.sporer at gmail.com>
> > >
> > > > What is the error message you're receiving?
> > > >
> > > > -----Ursprüngliche Nachricht-----
> > > > Von: flow3-general-bounces at lists.typo3.org
> > > > [mailto:flow3-general-bounces at lists.typo3.org] Im Auftrag von Sergio
> > > > Gesendet: Donnerstag, 3. Januar 2013 10:26
> > > > An: General discussion about FLOW3
> > > > Betreff: Re: [FLOW3-general] DateTime format in my view
> > > >
> > > > Not working :-(
> > > >
> > > > I was trying to change date format before the form is displayed in
> > > > the edit view, calling in an initializeEditAction() something like
> > this:
> > > >
> > > >
> > > > $this->arguments['workingDay']->getPropertyMappingConfiguration()->f
> > > > or
> > > > Proper
> > > >
> > > > ty('break')->setTypeConverterOption('TYPO3\Flow\Property\TypeConvert
> > > > er
> > > > \DateT
> > > > imeConverter',
> > > >
> > > >
> > > > \TYPO3\Flow\Property\TypeConverter\DateTimeConverter::CONFIGURATION_
> > > > DA
> > > > TE_FOR
> > > > MAT,
> > > > 'H:i');
> > > >
> > > > But that's not working neither.
> > > >
> > > >
> > > >
> > > >
> > > > 2013/1/3 David Sporer <david.sporer at gmail.com>
> > > >
> > > > > Try this:
> > > > > <f:form.textfield property="break.date" id="break"
> > > > > value="{break.date
> > > > > -> f:format.date(format:'d.m.Y H:i')}" />
> > > > >
> > > > >
> > > > > -----Ursprüngliche Nachricht-----
> > > > > Von: flow3-general-bounces at lists.typo3.org
> > > > > [mailto:flow3-general-bounces at lists.typo3.org] Im Auftrag von
> > > > > Sergio
> > > > > Gesendet: Donnerstag, 3. Januar 2013 10:00
> > > > > An: General discussion about FLOW3
> > > > > Betreff: Re: [FLOW3-general] DateTime format in my view
> > > > >
> > > > > Yes, but I don't need a formatted text, I need to show an "input"
> > > > > element for a form, something like this:
> > > > >
> > > > > <f:form.textfield property="break.date" id="break" />
> > > > >
> > > > > I assumed I couldn't do the next (I receive a syntax error):
> > > > >
> > > > > <f:form.textfield property="break.date" id="break"
> > > > > value="<f:format.date format="d.m.Y - H:i:s">{break.date}</f:
> > > > > format.date>
> > > > > " />
> > > > >
> > > > > Is there a way to mix these two things?
> > > > >
> > > > > Thanks in advance,
> > > > > Sergio
> > > > >
> > > > >
> > > > >
> > > > > 2013/1/2 David Sporer <david.sporer at gmail.com>
> > > > >
> > > > > > Hi Sergio,
> > > > > >
> > > > > > yes, this means you need to use the View Helper John mentioned.
> > > > > > E.g. use this in your template:
> > > > > > <f:format.date format="d.m.Y -
> > > > > > H:i:s">{pass.createdon}</f:format.date>
> > > > > >
> > > > > > Best regards
> > > > > > David
> > > > > >
> > > > > >
> > > > > > -----Ursprüngliche Nachricht-----
> > > > > > Von: flow3-general-bounces at lists.typo3.org
> > > > > > [mailto:flow3-general-bounces at lists.typo3.org] Im Auftrag von
> > > > > > Sergio
> > > > > > Gesendet: Mittwoch, 2. Januar 2013 18:26
> > > > > > An: General discussion about FLOW3
> > > > > > Betreff: Re: [FLOW3-general] DateTime format in my view
> > > > > >
> > > > > > Hi John,
> > > > > >
> > > > > > I think you misunderstood me: I know you can change that format
> > > > > > every time you create an object containing a DateTime property.
> > > > > > But I don't mean when CREATING or UPDATING the object, but
> > > > > > showing the form to edit before updating. I don't know why the
> > > > > > format of the date, despite it is saved as "H:i" in the
> > > > > > database, when showing, it is shown again in the default format
> > > > > > for my form input. If I
> > > > > > var_dump() my object, the property shows like this
> > > > > > again:
> > > > > >
> > > > > > *protected* 'date' =>
> > > > > > *object*(*DateTime*)[*1933*]
> > > > > > *public* 'date' => string '2013-01-02 18:18:51'
> *(length=19)*
> > > > > > *public* 'timezone_type' => int 3
> > > > > > *public* 'timezone' => string 'Europe/Berlin' *(length=13)
> > > > > >
> > > > > > *
> > > > > >
> > > > > > I would like the 'date' would show only "18:18".
> > > > > >
> > > > > > Sergio
> > > > > >
> > > > > >
> > > > > > 2012/12/28 John Small <flow3.tiny69 at net-con.net>
> > > > > >
> > > > > > > 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']
> > > > > > > ->**getPropertyMappingConfiguratio**n()
> > > > > > > ->forProperty('begin')
> > > > > > > ->setTypeConverterOption('**TYPO3\FLOW3\Property\**TypeConvert
> > > > > > > ->er
> > > > > > > ->\*
> > > > > > > ->*D
> > > > > > > ->at
> > > > > > > ->eTimeConverter',
> > > > > > >
> > > > > > > \TYPO3\FLOW3\Property\**TypeConverter\**DateTimeConverter::**C
> > > > > > > ON
> > > > > > > FI
> > > > > > > GU
> > > > > > > RA
> > > > > > > TION_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
> > > > > > >
> > > > > > >
> > > > > > > ______________________________**_________________
> > > > > > > FLOW3-general mailing list
> > > > > > > FLOW3-general at lists.typo3.org
> > > > > > > http://lists.typo3.org/cgi-**bin/mailman/listinfo/flow3-**gene
> > > > > > > ra
> > > > > > > l< ht tp
> > > > > > > ://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general>
> > > > > > >
> > > > > > _______________________________________________
> > > > > > FLOW3-general mailing list
> > > > > > FLOW3-general at lists.typo3.org
> > > > > > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> > > > > >
> > > > > > _______________________________________________
> > > > > > FLOW3-general mailing list
> > > > > > FLOW3-general at lists.typo3.org
> > > > > > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> > > > > >
> > > > > _______________________________________________
> > > > > FLOW3-general mailing list
> > > > > FLOW3-general at lists.typo3.org
> > > > > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> > > > >
> > > > > _______________________________________________
> > > > > FLOW3-general mailing list
> > > > > FLOW3-general at lists.typo3.org
> > > > > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> > > > >
> > > > _______________________________________________
> > > > FLOW3-general mailing list
> > > > FLOW3-general at lists.typo3.org
> > > > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> > > >
> > > > _______________________________________________
> > > > FLOW3-general mailing list
> > > > FLOW3-general at lists.typo3.org
> > > > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> > > >
> > > _______________________________________________
> > > FLOW3-general mailing list
> > > FLOW3-general at lists.typo3.org
> > > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> > >
> > > _______________________________________________
> > > FLOW3-general mailing list
> > > FLOW3-general at lists.typo3.org
> > > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> > >
> > _______________________________________________
> > FLOW3-general mailing list
> > FLOW3-general at lists.typo3.org
> > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> >
> > _______________________________________________
> > FLOW3-general mailing list
> > FLOW3-general at lists.typo3.org
> > http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> >
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>
More information about the FLOW3-general
mailing list