29.01.2026 | Peter Gerken

Manipulate Form Data before Submit

formDataManipulation.js
// Modifies form data on submit.
form.addEventListener("formdata", (e) => {
  const formData = e.formData;
  geoLocationFieldNames.forEach((name) => {
    formData.delete(name);
  });
});

Issue:

  • A list of teasers should be filtered by the set "area of detail" (boundaries) on an embedded map and additionaly by exposed filters
  • A filtered version of the view should be shareable by link, ensuring no items are unwantedly filtered out

Solution:

  • use "formdata event" which is supported by recent versions of all major browsers
  • form data is being manipulated on submit
  • map viewport boundaries will be injected into the get request, but not included into exposed filters

Conclusion:

Using the provided solution will enable sharing of a set filter and ensures that whoever opens the link will see all teasers corresponding to the exposed filters. The map will be fully zoomed out so no teasers are 'accidentally' filtered out.