Issue Bug Closed

#78607ValidationResults viewhelper for-attribute object handling

Matthias Krappitz 11/08/16, 15:32 updated 09/16/26, 19:23

Description

When you have a partial fluid template in your extbase / fluid extension for outputting the validation results of an object creation or updating, there seems to be a strange / unexpected behaviour to me, which can lead to a pitfall especially for developers new to extbase and fluid. The following example of passing the object {user} in e.g. EXT:somextension/Resources/Private/Templates/User/Edit.html and EXT:somextension/Resources/Private/Templates/User/New.html works fine. This seems strange to me as the object was assigned to both templates as a lowercase “user” and not as upper camelcase “User” via $this->view->assign(‘user’, $user):

...
<f:render partial="FormErrors.html" arguments="{object : User}" />
...

Whereas the partial EXT:somextension/Resources/Private/Partials/FormErrors.html looks like this:

...
<f:form.validationResults for="{object}">
...
</f:form.validationResults>
...

When I change the line in the template EXT:somextension/Resources/Private/Templates/User/Edit.html to the obviously correct way of spelling object “user”, it throws an uncaught TYPO3 Exception #1: PHP Warning: Illegal offset type in isset or empty in ../typo3/sysext/extbase/Classes/Error/Result.php line 214:

...
<f:render partial="FormErrors.html" arguments="{object : user}" />
...

When I change the line in the template EXT:somextension/Resources/Private/Templates/User/Edit.html to the obviously correct way of spelling object “user”, it still works fine though:

...
<f:render partial="FormErrors.html" arguments="{object : user}" />
...

I think this is a kind of unexpected / irrational behaviour and should be corrected, as it can lead to unnecessary confusion and frustration for beginner developers in extbase and fluid.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 3

  1. Georg Ringer commented and changed status New Closed <span data-processor="relativetime" data-value="2026-09-16T19:23:16+00:00" > 09/16/26, 19:23 </span>

    (Created with AI support)

    This can be closed. The behaviour reported in 2016 no longer exists in this
    form. Verified on current main:

    for= receives           result
    ----------------------  -------------------------------------
    an Extbase object       renders nothing at all
    an undefined variable   renders all validation results
    a correct string        correct results

    There is no PHP warning any more. Result::forProperty() is typed ?string,
    and Fluid casts the value before it ever reaches Result. The cast succeeds
    because AbstractDomainObject::__toString() returns
    @static::class . ‘:’ . $this->uid@, which makes every domain object implicitly
    @Stringable@. The for argument therefore becomes a string such as
    @Vendor\Model\User:12@ – a syntactically valid but non-existent property path,
    and an unknown path yields an empty result object. Hence no error, but nothing
    rendered either.

    The second observation (an undefined variable showing all errors) cannot be
    fixed in the ViewHelper. ViewHelperInvoker checks arguments with isset(),
    and isset(null) is false, so an argument that evaluates to null is
    indistinguishable from one that was never given and falls back to the default
    value ''. An empty for means “all results” by design.

    Making unknown property paths raise an error is not possible either.
    @Result::forProperty()@ is the very same API the validators use to build the
    result tree (CollectionValidator, AbstractGenericObjectValidator), so it
    has to create sub-results on demand. And on the reading side, “there is no
    sub-result for this path” cannot be told apart from “this property has no
    errors” – which is the normal state of every freshly rendered form. Throwing
    there would break every valid form.

    What did improve in the meantime: #73717 removed the most frequent real-world
    cause of “@f:form.validationResults@ renders nothing” – property paths of
    collection elements that could never match, because validation results of an
    @ObjectStorage@ were keyed by spl_object_hash() while the form fields address
    the same element by its position.

    additionally the following issues will be solved #85070 & #73717