[TYPO3-mvc] extbase/fluid: validating and manipulating data before saving?
S.Korth
s.korth at dms-arts.com
Wed May 12 16:26:12 CEST 2010
Sven Kalbhenn schrieb:
> Hi guys!
>
> I'm writing a new extension for "plane-reservations" with extbase and fluid.
> For the reservation, I need a frontend-form with a date- and time-field.
> If I understand everything right, I have to write a new ViewHelper for rendering the form.
> OK, but where is the correct place for the validation and transforming the posted values into a DateTime-Object?
>
> If I send the date as a string, I always get the error:
> "Tx_Planereservation_Domain_Model_Reservation::setStart() must be an instance of DateTime, string given in .../typo3conf/ext/planereservation/Classes/Domain/Model/Reservation.php"
>
> I think the setter-method of the model is the wrong place - because the persistent-manager will use this method as well.
> So, is the controller the correct place??? Or is there a mechanism - like the ViewHelpers - to validate and manipulate the data before saving it?
>
> Please, could someone push me in the right direction?
>
> CU...Sven Kalbhenn
>
Just another idea,
build a new Validator Class within
"Class/Domain/Validator/mydomainnameValidator.php".
Then inherit the TX_Extbase_Validation_Validator_AbtractValidator and
overwrite (you must overwrite) the isVaid() Funktion. You can also use
"$this->addError()" to get error flash messages.
Sascha
More information about the TYPO3-project-typo3v4mvc
mailing list