Skip to content

Commit

Permalink
[BUGFIX] Display the form containing invalid configuration
Browse files Browse the repository at this point in the history
The form framework adds a warning flash messages to
the page module in case a page contains a form content
element, having some error.

In case of a generic invalid form configuration,
the message now also displays the corresponding
form identifier of the form configuration,
containing the invalid configuration.

Resolves: #102557
Releases: main, 12.4
Change-Id: I592a415692822200608f218268f1406fc33df118
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82044
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
  • Loading branch information
o-ba committed Nov 29, 2023
1 parent e5bc06b commit 9421844
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions typo3/sysext/form/Classes/Hooks/FormPagePreviewRenderer.php
Expand Up @@ -83,21 +83,25 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
);
}
} catch (NoSuchFileException $e) {
$this->addInvalidFrameworkConfigurationFlashMessage($e);
$this->addInvalidFrameworkConfigurationFlashMessage($persistenceIdentifier, $e);
$formLabel = sprintf(
$this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.notExistingdPersistenceIdentifier'),
$persistenceIdentifier
);
} catch (ParseErrorException $e) {
$this->addInvalidFrameworkConfigurationFlashMessage($e);
$this->addInvalidFrameworkConfigurationFlashMessage($persistenceIdentifier, $e);
$formLabel = sprintf(
$this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.invalidFrameworkConfiguration'),
$persistenceIdentifier
);
} catch (\Exception $e) {
// Top level catch - FAL throws top level exceptions on missing files, eg. in getFileInfoByIdentifier() of LocalDriver
$this->addInvalidFrameworkConfigurationFlashMessage($e);
$formLabel = $e->getMessage();
$this->addInvalidFrameworkConfigurationFlashMessage($persistenceIdentifier, $e);
$formLabel = sprintf(
$this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.invalidFrameworkConfiguration.text'),
$persistenceIdentifier,
$e->getMessage()
);
}
} else {
$formLabel = $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.noPersistenceIdentifier');
Expand All @@ -111,13 +115,11 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
return $itemContent;
}

/**
* @param \Exception $e
*/
protected function addInvalidFrameworkConfigurationFlashMessage(\Exception $e)
protected function addInvalidFrameworkConfigurationFlashMessage(string $persistenceIdentifier, \Exception $e): void
{
$messageText = sprintf(
$this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.invalidFrameworkConfiguration.text'),
$persistenceIdentifier,
$e->getMessage()
);

Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/form/Resources/Private/Language/Database.xlf
Expand Up @@ -46,7 +46,7 @@
<source>"%s" (Invalid ext:form configuration).</source>
</trans-unit>
<trans-unit id="tt_content.preview.invalidFrameworkConfiguration.text" resname="tt_content.preview.invalidFrameworkConfiguration.text" xml:space="preserve">
<source>Invalid ext:form configuration. %s</source>
<source>Invalid ext:form configuration in form "%s": %s</source>
</trans-unit>
<trans-unit id="tt_content.preview.invalidFrameworkConfiguration.title" resname="tt_content.preview.invalidFrameworkConfiguration.title" xml:space="preserve">
<source>Invalid configuration.</source>
Expand Down

0 comments on commit 9421844

Please sign in to comment.