1

我已经查看这些文档https://learn.getgrav.org/forms/forms#multiple-forms 1 天了,但仍然无法看到我做错了什么。它填充两种形式的问题,但仅在此处列出的第一个:

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

我在我的列表中列出了两个表单配置,default.md然后它完美地呈现了页面,但是我呈现表单的两个地方我以以下方式呈现它们:

{% 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') } %}

我的想法为零,现在我只是对这里的任何解决方案视而不见,我希望这里有人可以帮助我。

4

1 回答 1

0

我认为您唯一的问题是您没有包含正确的模板。包含表单是通过包含表单插件提供的模板 forms/form.html.twig 来完成的。您可以在 user/plugins/form/templates 中找到此模板。此模板将获取您的表单定义并显示字段。所以改变你的包括:

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

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

应该管用。

希望能帮助到你!

于 2017-08-28T08:17:45.077 回答