1

I've been looking at these docs https://learn.getgrav.org/forms/forms#multiple-forms now for 1 day and still havent been able to see what im doing wrong. The issue it populates both form but ONLY with the first listed here:

forms:
  sign-up-form:
    title: Bolig i ....?
    fields:
      - name: navn
        label: navn
        placeholder: Navn
        autofocus: off
        autocomplete: off
        type: text
        validate:
          required: true
      - name: email
        label: email
        placeholder: Email
        autofocus: off
        autocomplete: off
        type: text
        validate:
          required: true
    buttons:
      - type: submit
        value: Skriv mig op
        classes: "button white"
    process:
      - email:
          from: "{{ config.plugins.email.from }}"
          to:
            - "{{ config.plugins.email.from }}"
            - "{{ form.value.email }}"
          subject: "[Feedback] {{ form.value.name|e }}"
          body: "{% include 'forms/sign-up-form/data.html.twig' %}"
      - save:
          fileprefix: feedback-
          dateformat: Ymd-His-u
          extension: txt
          body: "{% include 'forms/data.txt.twig' %}"
      - message: Tak for din henvendelse, vi vender tilbage
  footer-form:
    title: Interesseret i ....?
    fields:
      - name: navn
        label: navn
        placeholder: Navn
        autofocus: off
        autocomplete: off
        type: text
        validate:
          required: true
      - name: email
        label: email
        placeholder: Email
        autofocus: off
        autocomplete: off
        type: text
        validate:
          required: true
      - name: phone
        label: phone
        placeholder: Telefon
        autofocus: off
        autocomplete: off
        type: text
        validate:
          required: true
    buttons:
      - type: submit
        value: Ja tak kontakt mig
        classes: "button white"
    process:
      - email:
          from: "{{ config.plugins.email.from }}"
          to:
            - "{{ config.plugins.email.from }}"
            - "{{ form.value.email }}"
          subject: "[Interesse I ....] {{ form.value.name|e }}"
          body: "{% include 'forms/footer-form/data.html.twig' %}"
      - save:
          fileprefix: feedback-
          dateformat: Ymd-His-u
          extension: txt
          body: "{% include 'forms/data.txt.twig' %}"
      - message: Tak for din henvendelse, vi vender tilbage

Im listing both of the forms config in my default.md and then it renders the page perfectly but the two places i render the form i render them the following way:

{% include 'forms/sign-up-form/form.html.twig' with { form: forms('sign-up-form') } %}

{% include 'forms/footer-form/form.html.twig' with { form: forms('footer-form') } %}

I have zero idea, and now im just looking my self blind on any solutions here, i hope some one here could help me out.

Nopzen
  • 566
  • 2
  • 6
  • 19

1 Answers1

0

I think your only problem is that you are not including the correct template. Including a form is done by including forms/form.html.twig which is a template provided by the form plugin. You can find this template in user/plugins/form/templates. This template will fetch your form definition and display the fields. So changing your include with:

{% include 'forms/form.html.twig' with { form: forms('sign-up-form') } %}

{% include 'forms/form.html.twig' with { form: forms('footer-form') } %}

should work.

Hope it helps!

Paul Massendari
  • 417
  • 3
  • 6