[TYPO3-mvc] [fluid] error Klasse hinzufügen

hannes johannes.schantl at gmail.com
Mon Aug 2 10:54:31 CEST 2010


Hi,
I have the following problem. I've built a new Validator for validating 
a property of an user object. 

_User Validator (compares two password fields of similarity):_
class Tx_EfectoProcastme_Domain_Validator_UserValidator
    extends    Tx_Extbase_Validation_Validator_AbstractValidator
{
   
    /**
     * If the given blog is valid
     *
     * @param Tx_EfectoProcastme_Domain_Model_User $user The user
     * @return boolean true
     */   
    public function isValid($user)
    {
       
        if(! $user instanceof Tx_EfectoProcastme_Domain_Model_User)
        {
            $this->addError('The given Object is not a User.', 1280685780);
            return false;
        }
       
        if($user->getPassword() !== $user->getPasswordConfirmation())
        {
            $this->addError('Passwords do not match.', 1280685960);
            return false;
        }
        return true;
    }
}

With {error.message} : {error.code} it's possible to get the error 
message, but it isn't translated and the field doesn't receive an 
additional class (like f3-form-error).
So when I have the view with:

<f:for each="{error.errors}" as="errorDetail">
    <f:translate key="{formName}{error.propertyName}{error.code}"
        default="{errorDetail.message} (#{errorDetail.code})" />
</f:for>

the errors due to datatype validation is translated properly and the 
error class is added to the fields, but no result wheter the passwords 
match or not...
I'm thankful for any advices,

hannes


More information about the TYPO3-project-typo3v4mvc mailing list