Skip to content

Instantly share code, notes, and snippets.

@fago
Last active January 21, 2026 11:24
Show Gist options
  • Select an option

  • Save fago/2b9f64e3102720f52dfe3980a8f3db96 to your computer and use it in GitHub Desktop.

Select an option

Save fago/2b9f64e3102720f52dfe3980a8f3db96 to your computer and use it in GitHub Desktop.
fix-cache
diff --git a/modules/lupus_decoupled_form/src/Controller/CustomElementsFormControllerTrait.php
b/modules/lupus_decoupled_form/src/Controller/CustomElementsFormControllerTrait.php
index 1234567..abcdefg 100644
--- a/modules/lupus_decoupled_form/src/Controller/CustomElementsFormControllerTrait.php
+++ b/modules/lupus_decoupled_form/src/Controller/CustomElementsFormControllerTrait.php
@@ -44,6 +44,10 @@ trait CustomElementsFormControllerTrait {
foreach (['form_id', 'attributes', 'method'] as $key) {
$element->setAttribute($key, $form['#' . $key] ?? NULL);
}
+ // Do not cache forms for authenticated users to avoid cached CSRF tokens.
+ if (\Drupal::currentUser()->isAuthenticated()) {
+ $element->mergeCacheMaxAge(0);
+ }
return $element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment