[TYPO3-mvc] Validating multiple arguments in one custom validator
Henrik M. Rasmussen
henrik at mocsystems.com
Mon Mar 7 13:11:41 CET 2011
On 02/03/11 10.40, Nikolas Hagelstein wrote:
> Hi,
>
> Am 01.03.2011 15:34, schrieb Henrik M. Rasmussen:
>> Controller:
>> - newAction($someObject=null, $myArr=null)
>> - createAction($someObject, $myArr=null)
>>
> > [..]
>> But now I need access to the $myArr from within the validation of
>> $someObject. Any idea how this is possible?
>
> Well either use a custom validation within your controller like Peter
> suggested. Or rethink your "models".
>
> Real world example:
>
> Model User:
> ------------
> -username
> -firstName
> -lastName
> -password
> -email
>
>
> newAction($newUser, $passwordConfirmation) (you would like to compare
> $passwordConfirmation with user->password to see if both are equal ).
>
> So better:
> newAction($newUser, $password) {
> $newUser->setPassword($password);
> }
>
> where password is an object:
>
> Model password:
> ------
> -password
> -passwordConfirmation
> method toString (You could even take salted passwords into account here ).
>
> Hope this helps,
> Nikolas
>
>
Thanks for the suggestion Nikolas. In my situation however, this would
create some pretty weird domain models, since a lot of the data from
both the two arguments are needed to do the validation.
However in this situation Peter's suggestion worked beautifully. So
thanks again Peter :)
Best regards
Henrik
More information about the TYPO3-project-typo3v4mvc
mailing list