[TASK] Show speaking exception message if form definition is invalid 30/57330/2
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Fri, 22 Jun 2018 23:46:48 +0000 (01:46 +0200)
committerAndreas Wolf <andreas.wolf@typo3.org>
Sat, 23 Jun 2018 09:31:35 +0000 (11:31 +0200)
Show a speaking exception message within the frontend if the
form definition is invalid.

Releases: master, 8.7
Resolves: #85357
Change-Id: Ifcb0684c9b5136c5dee5ac6b54732fcde02d82cf
Reviewed-on: https://review.typo3.org/57330
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Björn Jacob <bjoern.jacob@tritum.de>
Tested-by: Björn Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
typo3/sysext/form/Classes/Domain/Factory/ArrayFormFactory.php
typo3/sysext/form/Classes/Mvc/Persistence/FormPersistenceManager.php

index bfbbd24..97448b7 100644 (file)
@@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Form\Domain\Configuration\ConfigurationService;
 use TYPO3\CMS\Form\Domain\Exception\IdentifierNotValidException;
+use TYPO3\CMS\Form\Domain\Exception\RenderingException;
 use TYPO3\CMS\Form\Domain\Exception\UnknownCompositRenderableException;
 use TYPO3\CMS\Form\Domain\Model\FormDefinition;
 use TYPO3\CMS\Form\Domain\Model\FormElements\AbstractSection;
@@ -40,6 +41,7 @@ class ArrayFormFactory extends AbstractFormFactory
      * @param array $configuration
      * @param string $prototypeName
      * @return FormDefinition
+     * @throws RenderingException
      * @internal
      */
     public function build(array $configuration, string $prototypeName = null): FormDefinition
@@ -49,6 +51,10 @@ class ArrayFormFactory extends AbstractFormFactory
         }
         $persistenceIdentifier = $configuration['persistenceIdentifier'] ?? null;
 
+        if ($configuration['invalid'] === true) {
+            throw new RenderingException($configuration['label'], 1529710560);
+        }
+
         $prototypeConfiguration = GeneralUtility::makeInstance(ObjectManager::class)
             ->get(ConfigurationService::class)
             ->getPrototypeConfiguration($prototypeName);
index 869de1d..c25499b 100644 (file)
@@ -111,6 +111,7 @@ class FormPersistenceManager implements FormPersistenceManagerInterface
             $yaml = $this->yamlSource->load([$file]);
         } catch (\Exception $e) {
             $yaml = [
+                'type' => 'Form',
                 'identifier' => $file->getCombinedIdentifier(),
                 'label' => $e->getMessage(),
                 'error' => [