Skip to content

Developers · Forms

Form Flash Messages

Last updated 1 November 2026

Show a one-time success or error message after a form is submitted, with flash_notice and flash_alert.

A flash message is a short notice shown once, on the next page someone sees, such as Thanks, your message was sent. Use one after a form is submitted, so people know whether it worked.

Tip

You can also set these messages without code in the form builder. See Form Builder.

Set the messages on a form

A form definition takes two keys: flash_notice for success and flash_alert for an error.

app/forms/signup_form.liquid

---
name: signup_form
resource: User
resource_owner: anyone
fields:
  email:
  password:
flash_notice: You have successfully signed up
flash_alert: Please fix the errors below
---

Show them in your layout

The messages are on context.flash. Render them in the layout, so they appear on every page:

app/views/layouts/application.liquid

{%- if context.flash.notice -%}
  <div class='flash notice' role='status'>{{ context.flash.notice }}</div>
{%- endif -%}
{%- if context.flash.alert -%}
  <div class='flash alert' role='alert'>{{ context.flash.alert }}</div>
{%- endif -%}

Example: read a form's messages

Query

{
  admin_forms(per_page: 50) {
    results { name flash_notice flash_alert }
  }
}

Response on the docs instance (shortened)

{
  "data": {
    "admin_forms": {
      "results": [
        {
          "name": "modules/ins_forms/documentation_suggest_changes",
          "flash_notice": "Successfully submitted form.",
          "flash_alert": "Failed to submit form. Please try again."
        }
      ]
    }
  }
}

This ran read-only on the docs.insites.io instance on 1 November 2026. Its suggest-changes form uses both keys. admin_forms is deprecated in the schema but still answers.

Pages that call GraphQL directly

A page that saves data with its own mutation has no form to set the message. Store it in the session before you redirect, and have the layout read and clear it. The Insites Logic Engine flash messages reference shows the full pattern, with a from path so the message clears once shown.

Common mistakes

  • Setting the messages but never rendering context.flash. Nothing appears.
  • Rendering the flash in only one page. Put it in the layout, because the next page is often a different one.
  • Putting user input into the message without escaping it.