Project

General

Profile

Actions

Bug #97557

closed

Confirmation finisher contentElementUid

Added by Katharina Strasser over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2022-05-05
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:
Remote Sprint

Description

Hello,
if I set want to override the formfinisher settings in a content-element "settings.overrideFinishers" and the Finisher "Confirmation" is active, the field "contentElementUid" is written to the database with the value "[Empty]".
Therefore, the output in the frontend is also blank, "settings.finishers.Confirmation.message" is not displayed.

But If I remove replace the "[Empty]" in the database (within the xml in the pi_flexform field) with nothing, then the frontend is working as intended and the message given in "settings.finishers.Confirmation.message" is shown again.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #96830: Forms: Confirmation message Finisher overriding issuesClosed2022-02-11

Actions
Related to TYPO3 Core - Bug #96478: PHP Warning: sprintf(): Too few arguments in FinisherOptionGenerator.php line 95Closed2022-01-07

Actions
Actions #1

Updated by Katharina Strasser over 2 years ago

Edit:
I was able to implement a quick workaround if this bug:

<?php

declare(strict_types=1);

/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */

namespace MyVendor\MyExt\FormFinishers;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Form\Domain\Finishers\Exception\FinisherException;
use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
use TYPO3\CMS\Form\ViewHelpers\RenderRenderableViewHelper;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

/**
 * A finisher that outputs a given text
 *
 * Options:
 *
 * - message: A hard-coded message to be rendered
 * - contentElementUid: A content element uid to be rendered
 *
 * Usage:
 * //...
 * $confirmationFinisher = $this->objectManager->get(ConfirmationFinisher::class);
 * $confirmationFinisher->setOptions(
 *   [
 *     'message' => 'foo',
 *   ]
 * );
 * $formDefinition->addFinisher($confirmationFinisher);
 * // ...
 *
 * Scope: frontend
 */
class ConfirmationFinisher extends \TYPO3\CMS\Form\Domain\Finishers\ConfirmationFinisher
{

    /**
     * Executes this finisher
     *
     * @see AbstractFinisher::execute()
     * @return string
     *
     * @throws FinisherException
     */
    protected function executeInternal()
    {

        $contentElementUid = $this->parseOption('contentElementUid');
        $typoscriptObjectPath = $this->parseOption('typoscriptObjectPath');
        $typoscriptObjectPath = is_string($typoscriptObjectPath) ? $typoscriptObjectPath : '';
        if (!empty($contentElementUid) && $contentElementUid != '[Empty]') {
            $pathSegments = GeneralUtility::trimExplode('.', $typoscriptObjectPath);
            $lastSegment = array_pop($pathSegments);
            $setup = $this->typoScriptSetup;
            foreach ($pathSegments as $segment) {
                if (!array_key_exists($segment . '.', $setup)) {
                    throw new FinisherException(
                        sprintf('TypoScript object path "%s" does not exist', $typoscriptObjectPath),
                        1489238980
                    );
                }
                $setup = $setup[$segment . '.'];
            }
            $this->contentObjectRenderer->start([$contentElementUid], '');
            $this->contentObjectRenderer->setCurrentVal((string)$contentElementUid);
            $message = $this->contentObjectRenderer->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.'], $lastSegment);
        } else {
            $message = $this->parseOption('message');
        }

        $standaloneView = $this->initializeStandaloneView(
            $this->finisherContext->getFormRuntime()
        );

        $standaloneView->assignMultiple([
            'message' => $message,
            'isPreparedMessage' => (!empty($contentElementUid) && $contentElementUid != '[Empty]'),
        ]);

        return $standaloneView->render();
    }

}

The only thing it does different is a an additional condition "$contentElementUid != '[Empty]'"

Actions #2

Updated by Joey Bouten over 2 years ago

  • Related to Bug #96830: Forms: Confirmation message Finisher overriding issues added
Actions #3

Updated by Björn Jacob over 2 years ago

  • Sprint Focus set to Remote Sprint
Actions #4

Updated by Mathias Brodala over 2 years ago

  • Is Regression set to Yes
Actions #5

Updated by Mathias Brodala over 2 years ago

  • Related to Bug #96478: PHP Warning: sprintf(): Too few arguments in FinisherOptionGenerator.php line 95 added
Actions #6

Updated by Gerrit Code Review over 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74999

Actions #7

Updated by Anonymous over 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #8

Updated by Benni Mack about 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF