Raven Forms for Statamic Websites

Raven Forms for Statamic Websites

Earlier I mentioned developing websites with Statamic, a flat-file PHP-based CMS. I also mentioned a couple of Statamic Add-Ons, Raven Forms and Bloodhound Search, that are purchased separately from Statamic. Although I'd prefer it be bundled with Statamic, Raven Forms is an extremely easy-to-use forms solution for Statamic websites that allows you to use your own custom form markup, declare formsets declaratively via a YAML configuration file, capture form data as flat-files, email form data, neutralize spam via Akismet, and review and manage form submissions using a custom control panel complete with metrics and statistics.

Raven Forms

Raven Forms for Statamic mainly consists of 3 pieces:

  • Form Tags - These are tags like {{ raven:form formset="contact" }} ... {{ /raven:form }}, {{ raven:errors }}, {{ raven:success }}, {{ raven:has_errors }} and other related tags that you use on your website pages as helpers to correctly add form tags, show errors, and make decisions based upon the success and failure of form data submission.
  • Formsets - Each form on your website is a formset. Formsets allow you to configure each form separately, specifying which fields are captured and validated, where form data is stored, if form data is sent via email, spam filtering, and other configuration information.
  • Control Panel - Each formset can have its own control panel, allowing you to view form submissions, manage those submissions, and view metrics and statistics related to form submissions.

Raven Forms Statamic

In the photo above, you will notice a sample control panel for a Raven Formset. This is for a Contact Form on a Statamic Website that captures name, email, phone, and a comment and displays them in the control panel. A single metric is defined in the control panel to display the total number of submissions. Although not shown, all form submissions are sent via email using Mandrill.

Form Tags

Raven Form Tags make it very easy to incorporate Raven Forms into your Statamic Website using existing HTML markup. Here is a snippet from the Raven Contact Form showing the bare minimum needed to specify the formset for the form. For brevity, I removed all the Raven Form Tags associated with errors and success, which you can read more about in the documentation. As you can see, it is really very easy specifying a form and formset using Raven.

{{ raven:form formset="contact" }}

<label>Name:</label>
<input type="text" name="name" value="{{ value:name }}">

{{ /raven:form }}

Formsets

Formsets for Raven are declared in YAML declaratively and make it really easy to configure forms. Formsets allow you to specify which form fields are captured and displayed in the control panel, where form data is saved, email notifications, spam filtering, and form field validation. The Raven Formset is very intuitive, making it very easy to configure forms in your Statamic Website. Here is just a snippet. The sample Raven Formset comes with plenty of comments to help you fill it out. I removed them just to keep it simple and show the facts.

allowed:
  - name
  - email
  - phone
  - comment

required:
  - name
  - email

validate:
  email: email

control_panel:

  fields:
    - name
    - email
    - phone
    - comment
    
  metrics:
    -
      type: count
      field: email
      label: Total Submissions

Again, Raven configuration is declarative, allowing you to create forms in minutes.

Conclusions

Hope you found this quick peek at Raven Forms useful. I am very happy to be developing Statamic Websites for my clients, and Raven Forms makes developing forms really easy. If you are interested in having me develop a Statamic Website for you, please contact me. I am a Statamic Developer for Hire!