<form> on an ElasticFunnels page can store its entries in a collection. The builder does this for you when you drag a form onto the page. This page is for when you write the HTML yourself: in the code editor, with the ef CLI, or with an AI agent.
A form needs two things:
- A collection with one field for each input you want to keep.
- A form whose
actionis/api/collection/<code>/store, where<code>is the collection’s code.
With the ef CLI or an AI agent
If you work with theef CLI, the fastest route is to ask your agent. ef init (and ef claude) writes the ElasticFunnels guidance into your project’s CLAUDE.md, and ef codex writes the same into AGENTS.md. That guidance covers forms and collections, so in Claude Code you can say “add a form that collects phone numbers to the landing page” and it creates the collection and writes the markup.
To do it yourself, create the collection first and note the code it prints:
--field is name:type[:required]. Types are text, email, number, checkbox, password, textarea, select and hidden.
Then point the form at it:
Without the CLI
- Go to Pages → Advanced → Collections and click Create Collection.
- Add one field per input, named exactly like the input’s
nameattribute (see the warning above). - Save, and copy the collection’s code.
- Paste the form above into your page’s code, with your code in place of
4k2xqa.
Let ElasticFunnels create the collection
You can also write a plain form with noaction:
action, adds data-collection attributes and inserts success and error message elements. ef push prints the new code and saves the rewritten HTML back into your local file, so open the file again before your next edit.
Two limits:
- It is skipped when the page contains template syntax anywhere (
{{ }},@if,@foreach,@set,@extends). Use the route above for those pages. - Any form with a non-empty
actionthat is not/api/collection/.../storeis left alone. Use that for search boxes or forms that post somewhere else.
Full example: a form that collects phone numbers
One phone field and a checkbox that starts unticked. Hidden fields keep the exact wording shown next to the box, the page address and the time the visitor submitted. Tested on a live demo page. Create the collection:0ws38w and your own wording and links:
:required from sms_opt_in and the required attribute from the checkbox.
An entry is stored data only. Saving it doesn’t add the number to any text message list and doesn’t send a text to anyone.
How the form behaves
ElasticFunnels’ page script sends every form whoseaction starts with /api/ and shows the result, without reloading the page.
- Errors. Server errors (“phone is required”, “Your session has expired”) appear in the element with
data-form-error-message. Without one, a red box appears above the submit button. - Success. The element with
data-form-success-messageshows “Thank you for submitting the form.” and the form is cleared. Saving the page resets thedata-success-messageattribute, so for your own wording use theon-form-successevent as in the example. - Redirect. Add
data-redirect-url="/thank-you"to the<form>to send the visitor to another page after a successful entry. - Checks. Required fields, email fields and number fields are checked on the server. Text fields are also screened for random-looking spam text. If the collection has reCAPTCHA v3 turned on, put
<div data-recaptcha-v3="true" data-site-key="YOUR_SITE_KEY"></div>inside the form. - Session. The form only works on pages served by ElasticFunnels. It sends a security token from the page, so a copy of the form on another site is rejected.
Where entries show up
- Collections. Go to Pages → Advanced → Collections and open the collection to see each entry with its fields.
- CRM. Every collection has a matching CRM entity, and each entry is also a record there.
- CLI.
ef collections entries <code>lists the stored entries. - Export. Download entries as CSV, see Export form data.