[BUGFIX] Fixes errors that occur when the same form is used multiple times on the same page #247
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are currently some issues when using the same form multiple times on the same page (tested with
TYPO3 v8.7.10
andpowermail v5.5.0
):This pull request fixes the issues the following way:
__ttcontentuid
to the form containing the content element uid__ttcontentuid
inFormController->forwardIfTtContentUidDoesNotMatch
and forwarding toformAction
if the uids do not matchPrefillViewHelpers
and only prefill from GET / POST variables if the content uids do matchdata-powermail-ttcontentuid
instead ofdata-powermail-form
I am storing the data array of the current content object into
GLOBALS['TSFE']->applicationData
for two reasons (https://github.com/maechler/powermail/blob/develop/Classes/Controller/FormController.php#L478-L496):errorAction
is called after the validation failed. TheerrorAction
redirects to the referring actionformAction
and thus the data array is missing whenformAction
wants to render the template. That means that the hidden field__ttcontentuid
can not be filled in correctly when there are server side validation errors.PrefillViewHelpers
, like this it is easily accessible. Another way would be to pass the data down fromForm.html
to the field templates (e.g.Input.html
), but that would have a bigger impact on existing code.If you have any suggestions to improve the code I would be happy to update the pull request.