Issue Bug Resolved

#92406Using formvh:render without extbase context results in Exception

Daniel Siepmann 09/25/20, 11:17 updated 10/15/26, 18:05

Description

Using
<formvh:render persistenceIdentifier="EXT:sitepackage/Resources/Private/Forms/enquiry.form.yaml" />
inside an arbitrary Fluid template results in
Argument 1 passed to TYPO3\CMS\Extbase\Service\ExtensionService::getPluginNameByAction() must be of the type string, null given, called in /var/www/html/public/typo3/sysext/extbase/Classes/Mvc/Web/Routing/UriBuilder.php on line 609
. It looks like the reason is
$form = $formDefinition->bind($renderingContext->getControllerContext()->getRequest(), $response);
inside the ViewHelper.

I guess it should be possible to detect the state, and create a fake request with the expected defaults to the EXT:form plugin itself to make it way easier. Alternatively one could set the necessary info through additional arguments. Just like in the example when using FLUIDTEMPLATE: https://docs.typo3.org/c/typo3/cms-form/10.4/en-us/I/Concepts/FrontendRendering/Index.html#render-through-fluidtemplate-without-controller

It would make usage of EXT:form much easier if that would work out of the box.

Reviews 7

History 1286

Show 361 earlier messages
  1. Gerrit Code Review pushed patch set 7 for master to change 70460 status New Under Review <span data-processor="relativetime" data-value="2021-08-12T22:15:50+00:00" > 08/12/21, 22:15 </span>

  1. Ralf Zimmermann commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2022-07-02T14:05:19+00:00" > 07/02/22, 14:05 </span>

    Applied in changeset commit:667346aee4ca1ee22e0530dbfdc71f84fb2b1aa0.

  2. Gerrit Code Review pushed patch set 4 for 11.5 to change 75013 status Resolved Under Review <span data-processor="relativetime" data-value="2022-07-02T17:36:48+00:00" > 07/02/22, 17:36 </span>

  3. Ralf Zimmermann commented and changed status Under Review Resolved <span data-processor="relativetime" data-value="2022-07-12T08:25:22+00:00" > 07/12/22, 08:25 </span>

    Applied in changeset commit:9f933f2cf1c05709962c9efa2dd1951e7ad9a6a7.

  4. Tim Obert commented <span data-processor="relativetime" data-value="2022-07-18T07:10:23+00:00" > 07/18/22, 07:10 </span>

    Is there already a plan when the patch for 10.4 will be started?

  5. Gerrit Code Review pushed patch set 9 for 10.4 to change 70513 status Resolved Under Review <span data-processor="relativetime" data-value="2022-07-28T14:23:57+00:00" > 07/28/22, 14:23 </span>

  6. Daniel Siepmann commented <span data-processor="relativetime" data-value="2024-01-05T11:06:01+00:00" > 01/05/24, 11:06 </span>

    Looks like the issue still exists in TYPO3 v12:

    (1/1) TypeError
    
    TYPO3\CMS\Form\Domain\Model\FormDefinition::bind(): Argument #1 ($request) must be of type TYPO3\CMS\Extbase\Mvc\RequestInterface, TYPO3\CMS\Core\Http\ServerRequest given, called in /vendor/typo3/cms-form/Classes/ViewHelpers/RenderViewHelper.php on line 97

    We have the following “workaround”:

    TypoScript:

        variables {
            form = COA
            form {
                5 = USER
                5 {
                    userFunc = Codappix\SiteCodappix\UserFunc\Form->prepare
                }
                10 = EXTBASEPLUGIN
                10 {
                    extensionName = Form
                    pluginName = Formframework
                }
            }
        }

    The UserFunction is executed prior the plugin and will populate the pi_flexform accordingly.
    Minimum example:

    <?php
    
    declare(strict_types=1);
    
    namespace Codappix\SiteCodappix\UserFunc;
    
    use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
    use TYPO3\CMS\Core\Utility\GeneralUtility;
    use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
    
    final class Form
    {
        private ContentObjectRenderer $renderer;
    
        public function setContentObjectRenderer(ContentObjectRenderer $renderer): void
        {
            $this->renderer = $renderer;
        }
    
        public function prepare(
        ): string {
            $flexForm = [
                'data' => [
                    'sDEF' => [
                        'lDEF' => [
                            'settings.persistenceIdentifier' => $this->renderer->data['codappix_form'] ?? '',
                        ],
                    ],
                ],
            ];
    
            $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
    
            $this->renderer->data['pi_flexform'] = $flexFormTools->flexArray2Xml($flexForm, true);
            return '';
        }
    }

    This can be fine tuned per case, e.g. use configuration to dynamically fetch the identifier from somewhere else, merge it with existing pi_flexform, etc.

    One than can use the following in Fluid:

    {form -> f:format.raw()}
  7. Josua Vogel commented <span data-processor="relativetime" data-value="2026-05-14T09:17:03+00:00" > 05/14/26, 09:17 </span>

    The issue is still present in v14 and current main

  8. Benni Mack commented and changed status Under Review Resolved <span data-processor="relativetime" data-value="2026-10-15T18:05:15+00:00" > 10/15/26, 18:05 </span>

    Applied in changeset commit:10377a28e25d9db86c133fc7aeaa35cc3bde4be4.