Skip to content

Create Contact Form

A mail form is a simple tableless form that submits to an email address and stores the data in a contact form table in heatwave

You need two files:

  1. A model definition. Stored under app/models/mail_form
  2. A html form. Stored under app/views/contact_forms

In app/models/mail_form just take one that exists and copy it to the name you want

if your new form is enroll_special_program then in the model you call it

class MailForm::EnrollSpecialProgram …

Then you add all the attributes in store_accessor, leave the first one :object that’s where i store stuff so

store_accessor :object, :attribute1, :attribute2, etc.

Then you repeat this below

attribute :attribute1 attribute :attribute2 etc

If the field is required, you add ”, validate: true” next to the attribute

so attribute :attribute1, validate: true

Create the form of the same name under

app/views/contact_forms

In our example it would be enroll_special_program.html.erb

from there just copy / paste from one of the other example

what’s important, your form tag references the form name (note its - not _ here):

<%= form_with model: @form_object, scope: :contact_form, url: cms_link(‘/contact/enroll-special-program/send’), method: :post, local: true do |f| %> … all my form stuff

<% end %>