Issue Bug Closed

#99243Wrong behaviour when using property and value together

Josua Vogel 12/02/22, 07:56 updated 10/15/24, 09:30

Description

According to the docs, name and value should be ignored, if property is set. I`m using the view helper like this:

<f:form.textfield
                    id="{id}"
                    name="customName"
                    property="{property}"
                    value="customValue"
                    placeholder="{placeholder}"
                    class="input__field form-control{f:if(condition: '{class}', then: ' {class}')}"
                    errorClass="{errorClass}"
                    additionalAttributes="{additionalAttributes}"
                    data="{data}"
                    aria="{describedby: 'error-label-{id}'}"
                />

This is the result:

<input required="required" aria-describedby="error-label-email" class="input__field form-control" id="email" type="text" name="tx_myextension[customerData][email]" value="customValue">

The name attribute is ignored, but not the value attribute.
I´m not sure, what is wrong. Maybe the code, maybe the docs.

Inside the view helper, I found this part:

* The value is determined as follows:
     * * If property mapping errors occurred and the form is re-displayed, the *last submitted* value is returned
     * * Else the bound property is returned (only in objectAccessor-mode)
     * * As fallback the "value" argument of this ViewHelper is used
if ($this->respectSubmittedDataValue) {
            $value = $this->getValueFromSubmittedFormData($value);
        } elseif ($this->hasArgument('value')) {
            $value = $this->arguments['value'];
        } elseif ($this->isObjectAccessorMode()) {
            $value = $this->getPropertyValue();
        }

I can fix this, if someone tells me, which would be the correct behaviour.

Reviews 2

History 613

  1. Gerrit Code Review pushed patch set 1 for main to change 77681 status New Under Review 02/03/23, 13:50

  2. Gerrit Code Review pushed patch set 2 for main to change 77681 02/07/23, 07:10

  3. Gerrit Code Review pushed patch set 3 for main to change 77681 02/07/23, 08:25

  4. Gerrit Code Review pushed patch set 4 for main to change 77681 03/14/23, 10:22

  5. Gerrit Code Review pushed patch set 5 for main to change 77681 03/14/23, 12:39

  6. Gerrit Code Review pushed patch set 6 for main to change 77681 05/03/23, 09:41

  7. Simon Praetorius changed Duplicated by #93527 10/19/23, 09:54

  8. Benni Mack changed status Under Review New 07/29/24, 21:40

  9. Gerrit Code Review pushed patch set 1 for main to change 85413 status New Under Review 07/30/24, 09:40

  10. Garvin Hicking commented 07/30/24, 09:41

    Previous patch has been abandoned with a discussion about “intentional behavior” of the “value” attribute.
    One possible example why both attributes together may make sense is a form to edit a user. For the password field you would want to define property=“password”, but also value=”“ to not expose the current password hash to the form.

    Thus, the new patch adjusts the inline code comment to reflect that intention.

  11. Garvin Hicking changed assigned to Garvin Hicking 07/30/24, 09:41

  12. Garvin Hicking commented and changed status Under Review Resolved done 0 % 100 % 07/30/24, 12:10

    Applied in changeset commit:ca8f1f9f9240e80a222e99b7b404226f4caddf90.

  13. Benni Mack changed status Resolved Closed 10/15/24, 09:30