Skip to content
Snippets Groups Projects
Commit d3d8bc04 authored by Elias Häußler's avatar Elias Häußler Committed by Oliver Hader
Browse files

[BUGFIX] Do not hide ContentObjectRenderer on form rendering

With #93887 (respectively #92406), a more convenient rendering
mechanism for forms was introduced. A new FormRequestHandler
centralized all the logic from the <formvh:render> view helper
to allow smoother form handling. However, the new implementation
used to hide the current ContentObjectRenderer implementation
and instead always fetched a new instance with
GeneralUtility::makeInstance().

This no longer allows to determine the current content object
rendering context from e.g. form finishers. Since the current
implementation can be retrieved by the ConfigurationManager,
it is now used in the <formvh:render> view helper, falling
back to a new ContentObjectRenderer instance in case the
ConfigurationManager does not actually provide an instance
of ContentObjectRenderer.

Resolves: #97977
Related: #93887
Related: #92406
Releases: main, 11.5
Change-Id: Iabf4e93e6aff8da742321958730521ef1696f130
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75247


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarwaldhacker <hello@waldhacker.dev>
Tested-by: default avatartheline <typo3@root-access.de>
Tested-by: default avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: default avatarwaldhacker <hello@waldhacker.dev>
Reviewed-by: default avatartheline <typo3@root-access.de>
Reviewed-by: default avatarOliver Hader <oliver.hader@typo3.org>
parent 0303a9c1
Branches
Tags
No related merge requests found
......@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace TYPO3\CMS\Form\ViewHelpers;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Form\Core\FormRequestHandler;
use TYPO3\CMS\Form\Domain\Factory\ArrayFormFactory;
......@@ -64,7 +65,9 @@ final class RenderViewHelper extends AbstractViewHelper
{
$request = $renderingContext->getRequest();
$extensionName = $request instanceof Request ? $request->getControllerExtensionName() : 'Form';
return GeneralUtility::makeInstance(ContentObjectRenderer::class)->cObjGetSingle('USER', [
$contentObjectRenderer = self::getContentObjectRenderer();
return $contentObjectRenderer->cObjGetSingle('USER', [
'userFunc' => FormRequestHandler::class . '->process',
'persistenceIdentifier' => $arguments['persistenceIdentifier'],
'factoryClass' => $arguments['factoryClass'],
......@@ -74,4 +77,16 @@ final class RenderViewHelper extends AbstractViewHelper
'pluginName' => $request->getPluginName(),
]);
}
private static function getContentObjectRenderer(): ContentObjectRenderer
{
$configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class);
$contentObjectRenderer = $configurationManager->getContentObject();
if ($contentObjectRenderer === null) {
$contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
}
return $contentObjectRenderer;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment