Skip to content

Commit

Permalink
Fixed: Forms where multiple of the same handle exist on a page
Browse files Browse the repository at this point in the history
  • Loading branch information
bymayo authored Jun 8, 2022
1 parent 007315b commit 6312e03
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions templates/_components/form.twig
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{% set id = handle ~ '-' ~ random(1000, 9999) %}

{% set baseOptions = {
id: handle
id: id
} %}

{% if options is defined %}
{% set baseOptions = baseOptions|merge(options) %}
{% endif %}

<div x-data="form" x-init="dynamicForm('{{ handle }}')">
<div x-data="form" x-init="dynamicForm('{{ handle }}', '{{ formId }}')">

{% set form = craft.freeform.form(
handle,
Expand All @@ -21,9 +23,9 @@

document.addEventListener('alpine:init', () => {
Alpine.data('form', () => ({
dynamicForm(handle) {
dynamicForm(handle, id) {

form = document.getElementById(handle);
const form = document.getElementById(id);

fetch(
'{{ siteUrl }}dynamic/form?form=' + handle
Expand Down

0 comments on commit 6312e03

Please sign in to comment.