Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

This course is the most refreshing take on teaching design that I've come across.

— Mikaël Sévigny, Developer

Form Submission Repository

To work with the Form Submissions Repository, use the following Facade:

use Statamic\Facades\FormSubmission;

Methods

Methods Description
all() Get all form submissions.
whereForm($handle) Get submissions by form handle.
whereInForm($handles) Get submissions, across multiple forms. Accepts an array of form handles.
find($id) Get a form submission, by its submission ID.
make() Makes a new Submission instance
query() Query Builder

Querying

Examples

Get form submissions by form

FormSubmission::whereForm('postbox');

Get form submissions, between multiple forms

FormSubmission::whereInForm(['postbox', 'newsletter']);

Get a single submission to a form by its id

FormSubmission::find($id);

Get form submissions, filtered by field

FormSubmission::query()
->where('form', 'postbox')
->where('email', '[email protected]')
->get();

Creating

Start by making an instance of a form submission with the make method.
You need to pass in a Form instance before you can save a form submission.

$form = \Statamic\Facades\Form::find('postbox');
 
$submission = FormSubmission::make()->form($form);

To set submission data, you may call the ->data() method and pass an array:

$submission->data([
'name' => 'David Hasselhoff',
'email' => '[email protected]',
]);

Finally, save it. It'll return a boolean for whether it succeeded.

$submission->save(); // true or false
HR: Section
Learn More!

There is more to learn more in these related articles:

Docs

Tags

shipment-container

Repositories

HR: Section
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →