Bug #35894

CheckboxViewHelper and RadioViewHelper missing an existence check for formObject, and thus an exception is being thrown

Added by Sebastian Wojtowicz over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Must have
Category:
ViewHelpers
Start date:
2012-04-12
Due date:
% Done:

100%

Estimated time:
0.10 h
Has patch:
No

Description

Scenario:

Controller:
    indexAction(FormObject $formObject = NULL){ ... }
Template:
    <f:form ... object="{formObject}' >
        <f:form.checkbox property="somePropertyOfFormObject" value="yes"/>
        ...
 

This scenario fails with

#1243325768: No value found for key "TYPO3\Fluid\ViewHelpers\FormViewHelper->formObject" 

The problem is that in the CheckboxViewHelper and the RadioViewHelper we call $this->getPropertyValue() which callls $formObject = $this->viewHelperVariableContainer->get('TYPO3\Fluid\ViewHelpers\FormViewHelper', 'formObject'); even though we did not check if the formObject exists, so that instead we get thrown an exception.

For example in CheckboxViewHelper.php, Line 80 before we call getPropertyValue() we only check

if ($this->isObjectAccessorMode())

while all other [InputType]ViewHelper always check (in the getValue() function):
if ($this->isObjectAccessorMode() && $this->viewHelperVariableContainer->exists('TYPO3\Fluid\ViewHelpers\FormViewHelper', 'formObject'))

So I think that in CheckboxViewHelper, Line 80 and in RadioViewHelper, Line 81 there should also be the same check for the existence of the formObject. Unless someone knows of a better place to inject that bugfix.

Also available in: Atom PDF