[TYPO3-mvc] Best Practice? Mapping of DateTime in a simple Request (without a Domain Model)
Tim Schoch | GSTALTIG
tim.schoch at gstaltig.ch
Mon Mar 28 16:42:42 CEST 2011
Hello List
Here's my next Question. I've got a simple search form with a textfield, that should get turned into a DateTime Object. This DateTime will then be used to find the according item.
I tried to do it with @param DateTime but that will give throw new
Tx_Extbase_MVC_Exception_InvalidArgumentValue('The value was a simple type, so we could not map it
to an object. Maybe the @entity or @valueobject annotations are missing?', 1251730701);
@dontvalidate won't do anything.
I use the workaround to declare @param string and then convert it to a DateTime manually. The
drawback is, that the validation doesn't work. The user should be sent back to the form when he enters
anything that can not be converted to a DateTime.
What DID NOT work:
@param DateTime -> see Exception above
@dontvalidate $date -> no effect
@param string $date
@validate $date DateTime -> Exception DateTime expected, string given
@param string $date
public function foo( DateTime $date ) ->see Exception above
Fluid Template is:
<f:form action="...">
<f:form.textfield name="date" />
</f:form>
What is the suggested way of handling DateTimes without a Domain Model?
Tim
More information about the TYPO3-project-typo3v4mvc
mailing list