[TYPO3-mvc] Date examples, can't find any.

Nathan Lenz typo3 at k9tfk.com
Tue Jan 12 16:50:04 CET 2010


Christine Gerpheide wrote:
> Hi Nathan,
> 
> What I have done in my new.html is have the form field like you have yours:
> 
> <label for="startdate">Launch Date</label><br />
> <f:form.textbox property="startdate" /><br />
> 
> And the setStartdate() method creates the DateTime object:
> 
> /**
>  * Setter for startdate.  String provided must be able to be parsed with
> strtotime.
>  * For instance, 'October 29th, 2009', '10/29/2009', or '29.10.2009'.  If
> not provided,
>  * date defaults to today.
>  *
>  * @param string $startdate e.g. '10/29/2009', '29.10.2009', etc
>  * @return void
>  */
> public function setStartdate( $startdate) {
>  $this->startdate = new DateTime($startdate);
> }
> 
> Then in edit.html, you have to use the DateTime view helper to parse the
> date, which can then be edited:
> 
> <label for="startdate">Launch Date</label><br />
> <f:form.textbox property="startdate" value="<f:format.date
> format='{settings.dateFormat}'>{campaign.startdate}</f:format.date>"/><br />
> 
> Would love to know if there's a better way, but hope that helps!
> Christine
> 

Hi Christine,
That does make sense.  One concern is that the "default" input for the
setter is a DateTime object, so I wonder if any other magic within the
extBase/Fluid world will ever expect to send a DateTime object to the
setter instead of a string.

I think I'm going to create a new viewHelper so I can do it like this:

<myext:form.dateTextBox property="startdate" format="Y-m-d" />

I'll post it back here if I get it to work.
--Nathan



More information about the TYPO3-project-typo3v4mvc mailing list