When saving a form, it just reloads the form (nodes, other forms)

Created on 5 February 2022, over 2 years ago
Updated 28 March 2023, over 1 year ago

Problem/Motivation

When you try to save a node or another form, the data is not stored and you end up again on the form, with sometimes broken elements. There are no errors captured.

Steps to reproduce

The issue occurs because of the code inside the function buttonWasClicked in FormBuilder.php.
There's a check between the input and the element value in this function, to determine which button was clicked on the form.
But if you have a translation that contains a "\r\n" at the end of the translation, perhaps because the translations was copied from a word doc, the comparison does not work, as the first value only contains a newline, and the second also contains the carriage return.

Because the submit buttons fails to be discovered, the code keeps searching in sub-elements and eventually another button is used, as f.e. a file upload button.
But as this logic contains a form rebuild, the form thinks it is a multi-step form and it just loads the form instead of saving and returning to the correct destination.

Proposed resolution

The fix could be achieved by providing a trim around the values to ensure newlines and carriage returns are not part of the comparison.
If you have this issue, you could also just remove the newline from interface translation on the "Save" value, but that won't stop us from encountering this into the future again.

Remaining tasks

Please review the proposed solution.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Form 

Last updated about 8 hours ago

Created by

🇧🇪Belgium hoebekewim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024