Create an and validate Parent/Child Objects with Typo3 Extbase Fluid

I want to create a Parent Object in a Fluid View Form with several Child Objects in a StorageObject (1:n Relation). The FormData will be transferred to the database and in case of an error the validator of the NEW Property Mapper returns it. But only in the form field of the parent object the "f3-form-error" class appears. But nothing happens on inconsistent child objects.

(Working in Typo3 6.2.5)

As you can see in a short example below, the Propertymapping for the ChildObjects Authors doesn't get the given UID. Instead the Mapper gives an custom ID. I think this is the reason why the ValidationResult isn't returned to input box.

Please help!

Short Example:

//Controller

    public function initializeCreateAction() {
            $this->arguments->getArgument('newSubmission')->getPropertyMappingConfiguration()->allowProperties('authors');
            $this->arguments->getArgument('newSubmission')->getPropertyMappingConfiguration()->allowCreationForSubProperty('authors.*');
            $this->arguments->getArgument('newSubmission')->getPropertyMappingConfiguration()->forProperty('authors.*')->allowProperties('firstname');

        }

// Fluid

<f:form.textfield property="type" /><br />
    <f:for each="{authors}" as="author" key="uid" iteration="iterator">
  <f:form.textfield property="authors.{uid}.firstname" placeholder="Enter your first given name" />
</f:for>

// Debug

$result = $this->getControllerContext()->getRequest()->getOriginalRequestMappingResults();

//Output

array(19 items)
   newSubmission.type => array(1 item)
      0 => TYPO3\CMS\Extbase\Validation\Errorprototypeobject
         message => 'The given subject was NULL.' (27 chars)
         code => 1221560910 (integer)
         arguments => array(empty)
         title => '' (0 chars)
   newSubmission.authors.000000006200d7b200007f3972b36107.email => array(1 item)
      0 => TYPO3\CMS\Extbase\Validation\Errorprototypeobject
         message => 'The given subject was not a valid email address.' (48 chars)
         code => 1221559976 (integer)
         arguments => array(empty)
         title => '' (0 chars)
   newSubmission.authors.000000006200d7b400007f3972b36107.email => array(1 item)
      0 => TYPO3\CMS\Extbase\Validation\Errorprototypeobject
         message => 'The given subject was not a valid email address.' (48 chars)
         code => 1221559976 (integer)
         arguments => array(empty)
         title => '' (0 chars)
   newSubmission.authors.000000006200d7b700007f3972b36107.email => array(1 item)
      0 => TYPO3\CMS\Extbase\Validation\Errorprototypeobject
         message => 'The given subject was not a valid email address.' (48 chars)
         code => 1221559976 (integer)
         arguments => array(empty)
         title => '' (0 chars)

Upvotes: 0

Views: 2121

Answers (1)

after a few days of hard work I finally found a DIRTY solution. I wrote an own errorAction and overwrite the values. There must be a better Solution!!!! Here my Code:

 protected function errorAction() {


        //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->arguments->getValidationResults()->forProperty('newSubmission.authors'));
         $authorErrors = $this->arguments->getValidationResults()->forProperty('newSubmission.authors')->getSubResults();

         $i = 1;
         foreach ( $authorErrors  as $uid => $author) {
            foreach ( $author->getSubResults()  as $property => $error) {
               $this->arguments->getValidationResults()->forProperty('newSubmission.authors.'.$i.'.'.$property)->addError(new \TYPO3\CMS\Extbase\Error\Error('Error', time()));
            }
            $i++;
        }

}

Upvotes: 1

Related Questions