Display additional text under a form

Hello @all,

I am totally new to GRAV. I have just started a first project and created a form for my website. I used the form plugin, I see the text on the top of the form (the text I can edit with the editor). After the text the form is displayed as it should.

My question: How can I add additional text after the form e.g. a disclaimer or something else.

Best regards
Sam

@sam2105,

You might try the Spacer field (not the best name I must admit) field:

form:
  name: xyz
  fields:
    name:
      type: text
    test:
      type: spacer
      title: Disclaimer
      text: By submitting this form, your accept our privacy policy ...
      underline: true
  buttons:
    submit:
      type: submiit

Yielding:

Hello pamtbaau,

thank you for your answer. What I meant was to put text under the form, not inside. The text should appear after the submit button and not be part of the form.

Is this possible?

Greetings Sam

@sam2105, You could add a field in the frontmatter of the page and inherit and tweak form.html.twig. Write the value of the field from frontmatter below the output of the form.

Like:

// form.md
---
myExtraText: This is the text I would like to display below the form.
form:
  name: xyz
  ...
---
// form.html.twig: Inherited/overridden from user/plugins/form/form.htm.twig

...
{{ content|raw }}
{% include "forms/form.html.twig" %}

{{ page.header.myExtraText }}

Hello pamtbaau,

thank you very much. This works for me.

Some additional information for everybody facing the same problem. I used the default template and NOT the form template. And in the extended options I have to activate the option processing markdown AND twig.

Greetings Sam

@sam2105, It is a solution, but I’m not sure if it is a proper solution.

Markdown is for content, Twig for layout.

I do not consider a form part of the content and would therefor not use {% include "forms/form.html.twig" %} inside the markdown of default.md.

I would only mix Twig inside Markdown if there is no alternative.

Hello pamtbaau,

as mentioned in my initial post, I am totally new to GRAV.

Where do I have to put this part?

// form.html.twig: Inherited/overridden from user/plugins/form/form.htm.twig
.
.
.

And if I want the text under the form be formated (strong, h1, etc.) what to do? I have to learn more about twig, markdown and grav :slight_smile:

Thanks for your patience

Sam

@sam2105, First of all, your solution works and will not cause you issues.

However, if you want to go for the extra mile…

  • You’ll need a custom theme or an inheriting (aka child) theme. If using a downloaded theme, you will lose your changes when the theme gets updated.
    See Theme Inheritance.
  • Copy file /user/plugins/form/form.htm.twig into /user/mytheme/templates/ and add the following content:
    {{ page.header.myExtraText | markdown }}
    
    The value of field myExtraText will now be processed as Markdown.
  • Add the following Yaml with a Markdown value to the frontmatter of the page:
    ---
    ...
    myExtraText: "###Disclaimer\nCompany **Acme Corp** will not accept..."
    ---
    
    Note: In yaml, character # is used to denote comments. Because my sample starts with ###, the string needs to be surrounded by quotes. And since the string contains a newline, double quotes are needed.
    Btw. there are more ways to format long text values in Yaml. See the Yaml specs.
  • Result
    Untitled
1 Like

Thank you pamtbaau,

this helped me a lot to dive deeper into the structure from GRAV.

Best regards
Sam