Bug #58921

f:form.* VHs crash if NOT inside f:form but followed by f:form

Added by Aimo Künkel about 1 year ago. Updated about 1 year ago.

Status:New Start date:2014-05-19
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:-
Target version:-
Has patch:No Affected Flow version:Git master

Description

The f:form.* ViewHelpers work inside of forms and standalone, but they crash if used standalone and they are followed by any fluid form.

This works fine and results in a perfect html select:

<f:form.select name="select" options="{1: 'One', 2: 'Two', 3: 'Three'}" />

This also works fine and results in a submittable form:

<f:form action="some" name="form">
    <f:form.button type="submit">Go!</f:form.button>
</f:form>

This instead (both concatenated) ...

<f:form.select name="select" options="{1: 'One', 2: 'Two', 3: 'Three'}" />

<f:form action="some" name="form">
    <f:form.button type="submit">Go!</f:form.button>
</f:form>

... will throw the following error:
h3. #1243352010: The key "TYPO3\Fluid\ViewHelpers\FormViewHelper->formFieldNames" was already stored and you cannot override it.

I regard this as a bug and propose to let them produce the html select, followed by the submittable form.

I explain it this detailed because i had a discussion in IRC on what a developer would expect the output to be, but i definitely would like to have multiple forms on a page AND multiple independent inputs NOT inside of forms (for UI reasons, for JS handling, ...)

History

#1 Updated by Aimo Künkel about 1 year ago

Here's my backtrace as requested, should be the same for everyone who uses the provided snipped above

Uncaught exception #1243352010 in line 420 of /var/www/etg.dev/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/TYPO3_Fluid_ViewHelpers_FormViewHelper.php: The key "TYPO3\Fluid\ViewHelpers\FormViewHelper->formFieldNames" was already stored and you cannot override it.

71 TYPO3\Fluid\Core\ViewHelper\ViewHelperVariableContainer_Original::add("TYPO3\Fluid\ViewHelpers\FormViewHelper", "formFieldNames", array|0|)
70 TYPO3\Fluid\ViewHelpers\FormViewHelper_Original::addFormFieldNamesToViewHelperVariableContainer()
69 TYPO3\Fluid\ViewHelpers\FormViewHelper_Original::render("some", array|0|, NULL, NULL, NULL, NULL, "", "", array|0|, FALSE, FALSE, array|0|, NULL, NULL, NULL, FALSE)
68 call_user_func_array(array|2|, array|16|)
67 TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper::callRenderMethod()
66 TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper::initializeArgumentsAndRender()
65 TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode_Original::evaluate(TYPO3\Fluid\Core\Rendering\RenderingContext)
64 TYPO3\Fluid\Core\Parser\SyntaxTree\AbstractNode::evaluateChildNodes(TYPO3\Fluid\Core\Rendering\RenderingContext)
63 TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper::renderChildren()
62 TYPO3\Fluid\ViewHelpers\SectionViewHelper_Original::render()
61 call_user_func_array(array|2|, array|0|)
60 TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper::callRenderMethod()
59 TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper::initializeArgumentsAndRender()
58 TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode_Original::evaluate(TYPO3\Fluid\Core\Rendering\RenderingContext)
57 TYPO3\Fluid\View\AbstractTemplateView::renderSection("Content", array|1|, FALSE)
56 TYPO3\Fluid\ViewHelpers\RenderViewHelper_Original::render("Content", NULL, array|0|, FALSE)
55 call_user_func_array(array|2|, array|4|)
54 TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper::callRenderMethod()
53 TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper::initializeArgumentsAndRender()
52 TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode_Original::evaluate(TYPO3\Fluid\Core\Rendering\RenderingContext)
51 TYPO3\Fluid\Core\Parser\SyntaxTree\AbstractNode::evaluateChildNodes(TYPO3\Fluid\Core\Rendering\RenderingContext)
50 TYPO3\Fluid\Core\Parser\SyntaxTree\RootNode_Original::evaluate(TYPO3\Fluid\Core\Rendering\RenderingContext)
49 TYPO3\Fluid\Core\Parser\ParsingState_Original::render(TYPO3\Fluid\Core\Rendering\RenderingContext)
48 TYPO3\Fluid\View\AbstractTemplateView::render()
47 TYPO3\Flow\Mvc\Controller\ActionController_Original::callActionMethod()
46 Etg24\HV\Backend\Controller\AbstractBackendController::callActionMethod()
45 call_user_func_array(array|2|, array|0|)
44 Etg24\HV\Backend\Controller\AbstractBackendController::Flow_Aop_Proxy_invokeJoinPoint(TYPO3\Flow\Aop\JoinPoint)
43 Etg24\HV\Backend\Controller\FaqController::Flow_Aop_Proxy_invokeJoinPoint(TYPO3\Flow\Aop\JoinPoint)
42 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)
41 TYPO3\Flow\Security\Aspect\PolicyEnforcementAspect_Original::enforcePolicy(TYPO3\Flow\Aop\JoinPoint)
40 TYPO3\Flow\Aop\Advice\AroundAdvice::invoke(TYPO3\Flow\Aop\JoinPoint)
39 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)
38 Etg24\HV\Backend\Controller\AbstractBackendController::callActionMethod()
37 Etg24\HV\Backend\Controller\FaqController::callActionMethod()
36 call_user_func_array(array|2|, array|0|)
35 Etg24\HV\Backend\Controller\FaqController::Flow_Aop_Proxy_invokeJoinPoint(TYPO3\Flow\Aop\JoinPoint)
34 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)
33 TYPO3\Flow\Security\Aspect\PolicyEnforcementAspect_Original::enforcePolicy(TYPO3\Flow\Aop\JoinPoint)
32 TYPO3\Flow\Aop\Advice\AroundAdvice::invoke(TYPO3\Flow\Aop\JoinPoint)
31 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)
30 Etg24\HV\Backend\Controller\FaqController::callActionMethod()
29 TYPO3\Flow\Mvc\Controller\ActionController_Original::processRequest(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)
28 Etg24\HV\Backend\Controller\AbstractBackendController::processRequest(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)
27 call_user_func_array(array|2|, array|2|)
26 Etg24\HV\Backend\Controller\AbstractBackendController::Flow_Aop_Proxy_invokeJoinPoint(TYPO3\Flow\Aop\JoinPoint)
25 Etg24\HV\Backend\Controller\FaqController::Flow_Aop_Proxy_invokeJoinPoint(TYPO3\Flow\Aop\JoinPoint)
24 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)
23 TYPO3\Flow\Security\Aspect\PolicyEnforcementAspect_Original::enforcePolicy(TYPO3\Flow\Aop\JoinPoint)
22 TYPO3\Flow\Aop\Advice\AroundAdvice::invoke(TYPO3\Flow\Aop\JoinPoint)
21 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)
20 Etg24\HV\Backend\Controller\AbstractBackendController::processRequest(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)
19 Etg24\HV\Backend\Controller\FaqController::processRequest(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)
18 call_user_func_array(array|2|, array|2|)
17 Etg24\HV\Backend\Controller\FaqController::Flow_Aop_Proxy_invokeJoinPoint(TYPO3\Flow\Aop\JoinPoint)
16 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)
15 TYPO3\Flow\Security\Aspect\PolicyEnforcementAspect_Original::enforcePolicy(TYPO3\Flow\Aop\JoinPoint)
14 TYPO3\Flow\Aop\Advice\AroundAdvice::invoke(TYPO3\Flow\Aop\JoinPoint)
13 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)
12 Etg24\HV\Backend\Controller\FaqController::processRequest(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)
11 TYPO3\Flow\Mvc\Dispatcher_Original::dispatch(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)
10 TYPO3\Flow\Mvc\Dispatcher::dispatch(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)
9 call_user_func_array(array|2|, array|2|)
8 TYPO3\Flow\Mvc\Dispatcher::Flow_Aop_Proxy_invokeJoinPoint(TYPO3\Flow\Aop\JoinPoint)
7 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)
6 TYPO3\Flow\Security\Aspect\RequestDispatchingAspect_Original::blockIllegalRequestsAndForwardToAuthenticationEntryPoints(TYPO3\Flow\Aop\JoinPoint)
5 TYPO3\Flow\Aop\Advice\AroundAdvice::invoke(TYPO3\Flow\Aop\JoinPoint)
4 TYPO3\Flow\Aop\Advice\AdviceChain::proceed(TYPO3\Flow\Aop\JoinPoint)
3 TYPO3\Flow\Mvc\Dispatcher::dispatch(TYPO3\Flow\Mvc\ActionRequest, TYPO3\Flow\Http\Response)
2 TYPO3\Flow\Http\RequestHandler::handleRequest()
1 TYPO3\Flow\Core\Bootstrap::run()

HTTP REQUEST:
GET /login/redaktion/faq/showforobject?object%5B__identity%5D=243f3316-e13b-1855-c2cd-01fc180e0d71 HTTP/1.1
Host: preisser.etg.dev
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36
Referer: http://preisser.etg.dev/login/redaktion/object/showobject?object%5B__identity%5D=243f3316-e13b-1855-c2cd-01fc180e0d71
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en,de;q=0.8
Cache-Control: max-age=0

HTTP RESPONSE:
[response was empty]

#2 Updated by Aimo Künkel about 1 year ago

Fun fact: if you reverse the two like so:

<f:form action="some" name="form">
    <f:form.button type="submit">Go!</f:form.button>
</f:form>

<f:form.select name="select" options="{1: 'One', 2: 'Two', 3: 'Three'}" />

it works (if no fluid form follows).

#3 Updated by Aimo Künkel about 1 year ago

Adrian Föder made me try

    /**
     * Adds a container for form field names to the ViewHelperVariableContainer
     *
     * @return void
     */
    protected function addFormFieldNamesToViewHelperVariableContainer() {
        if (!$this->viewHelperVariableContainer->exists('TYPO3\Fluid\ViewHelpers\FormViewHelper', 'formFieldNames')) {
             $this->viewHelperVariableContainer->add('TYPO3\Fluid\ViewHelpers\FormViewHelper', 'formFieldNames', array());
         }
    }

in \TYPO3\Fluid\ViewHelpers\FormViewHelper::addFormFieldNamesToViewHelperVariableContainer
which makes it work.
Just as a hint.

Also available in: Atom PDF