Zum Inhalt springen

Fluid FormValidationErrors einem Property zuordnen

Erstellt am 19. Oktober 2011 · 2 Antworten · letzte Antwort am 24. Oktober 2011

Tags: Frage

BFSven ·

Hallo,

ich habe folgendes Problem. Ich hab ein Formular, dazu ein Model und an jeder Property eine Validation-Annotation. Nun hängt aber eine Property von einer anderen ab, dazu hab ich die Validierung im Controller an die Action geschrieben. Nun will ich aber diese Fehlermeldung an das Property binden. Hat jemand einen Tipp, wie ich das anstelle?

Gruß, Sven

xandio ·

Hallo!

Ich binde die Fehler innerhalb der isValid()-Funktion eines Validators folgendermaßen:

$notEmptyValidator = new Tx_Extbase_Validation_Validator_NotEmptyValidator();
			
if (!($notEmptyValidator->isValid($theCart->getFirstName()))) {
$this->errors['firstName'] = new Tx_Extbase_Validation_PropertyError('firstName');
$this->errors['firstName']->addErrors(array(new Tx_Extbase_Validation_Error(Tx_Extbase_Utility_Localization::translate('error.firstName.empty', 'registration'), '1312448731')));
$success = false;
}

Vielleicht hilft Dir das weiter.

Viele Grüße,
Xandi