Homepage

Flash Messages

Last edit: Jun 11, 2024

Flash messages are used to create notices and alerts, e.g. on form submission.

Setting form notice/alert values through Form

You can add values for flash messages as part of form configuration, for example:

---
name: signup_form
resource: User
fields:
  email:
  password:
flash_notice: You have successfully signed up
flash_alert: Please fix validation errors
---

Interpolation

Values for flash keys are processed using a Liquid parser, so they can be interpolated in the context of the current form:

---
name: signup_form
resource: User
fields:
  email:
  password:
  first_name:
    validation: { presence: true }
flash_notice: 'Thank you {{ form.first_name }}, you have successfully signed up!'
flash_alert: Please fix validation errors
---

Note

Quotes around the value of flash_notice are required if you interpolate Liquid code inside YAML

Displaying flash messages

Messages can be displayed on a page using the context variable.

{{ context.flash['notice'] }}
{{ context.flash['alert'] }}

Questions?

We are always happy to help with any questions you may have.

contact us