[TYPO3-mvc] Validating multiple arguments in one custom validator
Peter Bücker
news.naag at gmx.net
Tue Mar 1 16:09:43 CET 2011
Hello Henrik,
On 03/01/2011 03:34 PM, Henrik M. Rasmussen wrote:
> [...]
>
> Controller:
> - newAction($someObject=null, $myArr=null)
> - createAction($someObject, $myArr=null)
>
> When the new-form is submitted, the $someObject and $myArr is correctly
> instantiated and populated, and depending on a a custom validator for
> $someObj, the createAction is executed or the newAction is shown again.
> All fine.
>
> But now I need access to the $myArr from within the validation of
> $someObject. Any idea how this is possible?
>
> [...]
I did it like this: https://gist.github.com/849247. If you use this
controller as your base controller, you can add an annotation like
"@validateAll $foo $bar Tx_MyExt_Validation_Validator_FooBarValidator"
to a controller action and it will validate those two arguments using
Tx_MyExt_Validation_Validator_FooBarValidator->isValidAll($foo, $bar).
Your validator class should extend
Tx_Extbase_MVC_Controller_ArgumentsValidator and add errors to
$this->errors as you would do with any other validator.
Hope this works for you.
Regards,
Peter
More information about the TYPO3-project-typo3v4mvc
mailing list