diff options
authorAlex Pott2017-05-22 20:13:21 (GMT)
committerAlex Pott2017-05-22 20:13:21 (GMT)
commita83586c30bfd7ad8c711731909a05acb08352e02 (patch)
parenta12c564dc9a778bda535ce05c2dbe0d99ea20481 (diff)
Issue #2596597 by hchonov, sardara, claudiu.cristea, pfrenssen: [regression] Soft reload does not clean up user inputs like in D7 (Firefox only)
1 files changed, 11 insertions, 0 deletions
diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php
index c4a1fd2..be000dc 100644
--- a/core/lib/Drupal/Core/Form/FormBuilder.php
+++ b/core/lib/Drupal/Core/Form/FormBuilder.php
@@ -725,6 +725,17 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// submitted form value appears literally, regardless of custom #tree
// and #parents being set elsewhere.
'#parents' => ['form_build_id'],
+ // Prevent user agents from prefilling the build id with earlier values.
+ // When the ajax command "update_build_id" is executed, the user agent
+ // will assume that a user interaction changed the field. Upon a soft
+ // reload of the page, the previous build id will be restored in the
+ // input, causing subsequent ajax callbacks to access the wrong cached
+ // form build. Setting the autocomplete attribute to "off" will tell the
+ // user agent to never reuse the value.
+ // @see
+ '#attributes' => [
+ 'autocomplete' => 'off',
+ ],
// Add a token, based on either #token or form_id, to any form displayed to