Form Repository

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

use Statamic\Facades\Form;

Methods

Methods Description
all() Get all Forms
find($handle) Get Form by handle
make() Makes a new Form instance
Hot Tip!

The handle is the name of the form's YAML file.

Querying

Examples

Get a single form by its handle

Form::find('postbox');

Get all forms from your site

Form::all()

Get submissions to a form by its handle

Form::find('postbox')->submissions;

Get a single submission to a form by its id

Form::find('postbox')->submission($id);

Get the blueprint of a form

Form::find('postbox')->blueprint();

Creating

Start by making an instance of a form with the make method.
You need at least a handle before you can save a form.

$form = Form::make()->handle('feedback');

You may call additional methods on the entry to customize it further.

$form
->handle('postbox')
->honeypot('winnie-the-pooh')
->title('The Hundred Acre Wood');

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

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

There is more to learn more in these related articles:

Docs

Tags

Fieldtypes

HR: Section
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →