[TYPO3-mvc] yes, nested objects validation is a missing feature at current extbase version (1.3)
Eric S. Auchterberge
endurans at gmail.com
Fri Oct 21 00:39:24 CEST 2011
Hi Alisha,
You can easily access validation errors using Form.erros view helper.
As I have some nested objects I need to even access errors of each
propertyError object, somthing like:
In main template:
<f:render partial="FormErrors" />
and at FormErrors.html :
<f:form.errors>
<div class="error">
<h4>
Following fields has errors:
</h4>
<ul >
<f:for each="{error.errors}" as="errorDetail">
<f:for each="{errorDetail.errors}" as="subErrorDetail">
...
Greetings,
Eric
On Thu, Oct 20, 2011 at 6:03 PM, Alisha <mail at alisha-huber.de> wrote:
> I have a class Tx_xx_Domain_Validator_**CoupleValidator
> as described by you. I do not know what I must do even more.
>
> in my update action I use:
> @validate $couple Tx_xx_Domain_Validator_**CoupleValidator
>
> But how do I get the errors?
>
> in the update action I tried:
> $errors = $this->errors();
> $errors = $this->request->getErrors();
> if($errors){
> foreach ($errors as $error){
> foreach($error->getErrors() as $e) {
> $this->flashMessages->add($e->**getMessage());
> }}}
>
> but it do not work ..
>
> the only error : An error occurred while trying to call Tx_xx_Controller_*
> *CoupleController->**updateAction()
>
> Regards
> Alisha
>
> Couple has a 1:1 relation zu appM
>
> my validator-class:
> class Tx_Dancestudio_Domain_**Validator_CoupleValidator extends
> Tx_Extbase_Validation_**Validator_AbstractValidator {
>
>
> /**
> * @var $objectManager Tx_Extbase_Object_**ObjectManager
> */
> protected $objectManager;
>
> public function injectObjectManager(Tx_**Extbase_Object_ObjectManager
> $objMgr) {
> $this->objectManager = $objMgr;
> }
> /**
> * Checks if the given value is valid according to the validator.
> *
> * If at least one error occurred, the result is FALSE and any errors
> can
> * be retrieved through the getErrors() method.
> *
> * Note that all implementations of this method should set
> $this->errors() to an
> * empty array before validating.
> *
> * @param mixed $value The value that should be validated
> * @return boolean TRUE if the value is valid, FALSE if an error occured
> */
> public function isValid($value) {
> if(!is_object($value) || !$value instanceof
> Tx_Dancestudio_Domain_Model_**Couple) {
> return FALSE;
> }
>
> $appMValidator = $this->objectManager->get('Tx_**
> Extbase_Validation_**ValidatorResolver')->**getBaseValidatorConjunction('*
> *Tx_Dancestudio_Domain_Model_**Application');
> if (!$appMValidator->isValid($**value->getAppM())) {
> $this->errors[] = $this->createPropertyError('**appM',
> $appMValidator->getErrors());
>
> }
>
>
>
> return count($this->errors) == 0;
> }
>
> /**
> * @param string $propertyName
> * @param array $errors
> * @return Tx_Extbase_Validation_**PropertyError
> */
> protected function createPropertyError($**propertyName, array $errors)
> {
> $error = new Tx_Extbase_Validation_**PropertyError($propertyName);
> $error->addErrors($errors);
> return $error;
> }
> }
> ______________________________**_________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc@**lists.typo3.org<TYPO3-project-typo3v4mvc at lists.typo3.org>
> http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**
> project-typo3v4mvc<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc>
>
More information about the TYPO3-project-typo3v4mvc
mailing list