[TYPO3-mvc] Re: What kind of Validator do i need
Philipp
philippwrann at gmx.at
Thu Oct 10 07:54:35 CEST 2013
So refactored a few files to make this work again.
Had to try-and-error a lot.... and i dont know if my approach is correct.
Validator:
<?php
namespace Vendor\Contact\Domain\Validator;
/**
* @author Philipp Wrann
*/
class RequestValidator extends \TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator {
/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
* @inject
*/
protected $objectManager;
/**
* @var \Vendor\Contact\Domain\Service\RequestService
* @inject
*/
protected $requestService;
/**
* @param array $request
* @return \TYPO3\CMS\Extbase\Error\Result
*/
public function validate(array $request) {
$this->requestService->convert($request);
$messages = new \TYPO3\CMS\Extbase\Error\Result();
$className = get_class($request);
$validatorResolver = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver');
/* @var $validatorResolver \TYPO3\CMS\Extbase\Validation\ValidatorResolver */
$validator = $validatorResolver->getBaseValidatorConjunction($className);
/* @var $validator \TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator */
$result = $validator->validate($request);
$messages->merge($result);
return $messages;
}
}
?>
#####
and then dont call the f:form.errors ViewHelper, instead use the f:form.validationResults ViewHelper.
In there debug {_all} and you get your errors.
More information about the TYPO3-project-typo3v4mvc
mailing list