Issue Bug Under Review Quiet

#86829The errorClass doesn't work for non formObject fields

Bill Dagou 11/02/18, 04:45 updated 10/06/26, 16:06

Description

The code is something like below.

<f:form action="update" object="{object}" objectName="object">
    <f:form.textfield class="form-control" name="other[field]" errorClass="is-invalid" />
</f:form>

When I set the validation like NotEmpty for $other.field, and submit the form keeping the field empty, the class is-invalid is never added.

Reviews 1

History 511

  1. Bill Dagou commented <span data-processor="relativetime" data-value="2018-11-02T05:29:51+00:00" > 11/02/18, 05:29 </span>

    My fix was

        protected function getMappingResultsForProperty()
        {
            if ($this->isObjectAccessorMode()) {
                $originalRequestMappingResults = $this->getRequest()->getOriginalRequestMappingResults();
                $formObjectName = $this->viewHelperVariableContainer->get(
                    \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class,
                    'formObjectName'
                );
                return $originalRequestMappingResults->forProperty($formObjectName)->forProperty($this->arguments['property']);
            } elseif ($this->arguments['name']) {
                $originalRequestMappingResults = $this->getRequest()->getOriginalRequestMappingResults();
                return $originalRequestMappingResults->forProperty(str_replace(['[', ']'], ['.', ''], $this->arguments['name']));
            } else {
                return new \TYPO3\CMS\Extbase\Error\Result();
            }
        }

    in \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper

  2. Bill Dagou commented <span data-processor="relativetime" data-value="2023-09-22T06:16:27+00:00" > 09/22/23, 06:16 </span>

    The case is for validating a ValueObject in a <f:form>.</f:form>

  3. Simon Praetorius commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2023-10-19T09:42:50+00:00" > 10/19/23, 09:42 </span>

    Could you clarify why you don’t use property instead of name in <f:form.textfield />?

  4. Bill Dagou commented <span data-processor="relativetime" data-value="2023-10-19T12:33:00+00:00" > 10/19/23, 12:33 </span>

    Yes. Generally it’s for validating a ValueObject, especially in editAction($domainObject, $valueObject).

    In some of my projects, I need to validate the state in Address or a hex color code in Color, which are all ValueObjects. After I set all the validations up, the logic works and the code will not go to the persist part, but the errorClass is never added to the HTML element because of the current getMappingResultsForProperty() function.

    That’s why I’m asking for this change. Or, maybe I’m using the ValueObject in a wrong way.

  5. Gerrit Code Review pushed patch set 3 for main to change 81167 status Needs Feedback Under Review <span data-processor="relativetime" data-value="2025-01-13T11:23:04+00:00" > 01/13/25, 11:23 </span>