Feature #91419
openDisable caching on a per form basis
0%
Description
The form framework caches forms which causes issues when pre-filling fields with data. Any dynamic data retrieved via get params or database queries will be cached and can't be overridden until caches are deleted.
Current solutions found in the typo3 slack channel fx. include disabling caching completely for the render function in the form controller:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['Form']['plugins']['Formframework']['controllers'][\TYPO3\CMS\Form\Controller\FormFrontendController::class]['nonCacheableActions'][] = 'render';
This of course changes caching for all forms which is not really an ideal solution.
Another solution suggested was using USER_INT instead of USER like this:
tt_content.form_formframework.20 = USER_INT
This would allow for disabling the cache on a per page basis. However certain forms which need to be uncached may be inserted by editors on multiple pages and makes it necessary to keep track of page ids where such forms are present and add them to our Typoscript.
It would be great to be able to disable caches for certain form configurations, perhaps as a yaml property. I am not sure if caches could be easily disabled via the form api in hooks where dynamic data is added, if this is the case that would also work for me.
Updated by Martin Schulz over 3 years ago
Any news here? Iam on 10.4 building some forms that do prefilling by current fe_user?
Updated by Björn Jacob over 3 years ago
- Status changed from New to Closed
Thanks for your contribution :) We are working on a solution which will also be available for v10. Please see #93887 and #92406 / https://review.typo3.org/c/Packages/TYPO3.CMS/+/70460/. I am closing this issue since the patch will fix your problem.
Updated by Björn Jacob over 3 years ago
- Related to Bug #93887: Ext:Form Caching Determination breaking Ajax Request added
Updated by Björn Jacob over 3 years ago
- Related to Bug #92406: Using formvh:render without extbase context results in Exception added
Updated by Gerrit Code Review over 3 years ago
- Status changed from Closed to Under Review
Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/70460
Updated by Gerrit Code Review over 3 years ago
Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/70460
Updated by Gerrit Code Review over 3 years ago
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/70587
Updated by Simon Schaufelberger about 3 years ago
- Subject changed from Disable caching on a per form basis. to Disable caching on a per form basis
I'm also affected by this bug as I have a prefill typoscript config when logged in with data from fe_user.
Updated by Gerrit Code Review almost 3 years ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/70587
Updated by Tim Obert over 2 years ago
Any news here?
It seems that the patch is not compatible to the current state of the repo anymore and the workaround with "TYPO3_CONF_VARS" also doesn't seem to help.
Updated by Björn Jacob over 2 years ago
We are still working on this issue. ATM there is another core sprint. The changes are rather complex.
Updated by Alexander Grein over 1 year ago
The workaround to set `tt_content.form_formframework.20 = USER_INT` is not working under TYPO3 12, since it uses an EXTBASEPLUGIN content object now.
Disabling caching for all forms, feels very crude.
Updated by André Buchmann 3 months ago · Edited
Due to the switch from USER to EXTBASEPLUGIN the simple switch to USER_INT is not working anymore directly as Alexander Grein already stated.
For TYPO3 12 & 13 you need to add the userFunc definition back in to get it working:
tt_content.form_formframework.20 = USER_INT tt_content.form_formframework.20.userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
Still this is only a workaround and I would like to have a feature to disable the cache for a single form/form element. Here is my usecase:
Customers get indiviualized links to a form. The GET param is automatically prefilled in a field.
Custom typoscript only on the special form page to read the GET param (?foo=bar). The GET param is excluded from the chash generation ([FE][cacheHash][excludedParameters])
plugin.tx_form.settings { formDefinitionOverrides { // form identifier: test { renderables { // identifier: page-1 0 { renderables { // identifier: text-1 0 { defaultValue = TEXT defaultValue.data = gp:foo } } } } } } } // Disable caching for the form tt_content.form_formframework.20 = USER_INT tt_content.form_formframework.20.userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
When the cache is enabled the first param value is cached for all other calls. Can't have that for the personlized codes in my project :-)
Updated by Garvin Hicking 3 months ago
Don't hit me, but how about utilizing JavaScript to read the GET params and fill specific fields?
Then everything could be cached and you wouldn't need that custom form typoscript reading values...?
Updated by Simon Schaufelberger 3 months ago
For me that JavaScript solution wouldn't work. I'm reading values from the feusers table and fill it in