Task #69732
closedStory #69712: Further FormEngine development
Remove name="foo[bar]_hr" from input fields
100%
Description
In FormEngine most rendered fields consists of a form field that is used for display and a second (hidden) one that is used to transfer the real value to the DataHandler, example:
<input type="text" data-formengine-validation-rules="[]" data-formengine-input-params="..." id="formengine-input-55f4253656de0150227335" name="data[tt_content]243[header]_hr" value="" ... >
<input type="hidden" name="data[tt_content]243[header]" value="">
This issue is about "input" fields rendered by "InputElement" only: Both fields have the same "name" attribute, except that the displayed field has the suffix _hr (this is probably for "human readable").
This means, if pressing save, both (!) fields are transferred back to the server to the DataHandler, so PHP receives two fields:
data[aTable][aField]_hr = "shown value"
data[aTable][aField] = "real value"
The fun part is that PHP creates an array in _POST from the [ and ] things, so it will become $GLOBALS['_POST']['data']['aTable']['aField']. So, PHP has no idea on what to do with the _hr suffix and throws this away. So, it basically gets two fields with the same name submitted. The second field (that is always the hidden field) then overwrites the value of the first field. The result is then: $GLOBALS['_POST']['data']['aTable']['aField'] = "real value"
This is really funny, since it means that the value of the "_hr" field is always transmitted back to the server, and then thrown away when PHP creates $GLOBALS['_POST']. So basically, we're transmitting the double amount of data that is needed ...
Goal of this patch: Remove the name="" attribute from the input field for the InputElement altogether. This is valid HTML (having no name) and browsers will then just not send this value on submit to the server.
The tricky thing is, this _hr stuff is used by various javascript methods to update the hidden field if a user changed the visible field. So in JS, the name attribute is the connection between the two fields. This needs to change and the JS adapted accordingly. There probably needs to be some unique class, or lookup magic, or data- attribute or whatever per input element that is added to both fields, so the JS can work on it.
So: remove the name attribute, but adapt any JS in a way that the hidden field is still updated if the shown field changes. Most of this will affect the JS "eval" handling, but also the DateTime stuff and maybe some wizards. Basically, the first tab of ext:styleguide should compile most use cases already.
Updated by Morton Jonuschat about 9 years ago
- Status changed from New to In Progress
Updated by Morton Jonuschat about 9 years ago
- Category set to FormEngine aka TCEforms
Updated by Gerrit Code Review about 9 years ago
- Status changed from In Progress to Under Review
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/43254
Updated by Christian Kuhn about 9 years ago
Don't know why this issue wasn't closed automatically.
It was merged with https://review.typo3.org/#/c/43254/
Updated by Christian Kuhn about 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Updated by Anja Leichsenring almost 9 years ago
- Sprint Focus deleted (
On Location Sprint)
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed