Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

Bought Jack McDade's course on design. Going through it now...and it is SO well done!

— Justin Jackson, Transistor.fm

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
findOrFail($handle) Get Form by handle. Throws a FormNotFoundException when the form cannot be found.
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');

When a form can't be found, the Form::find() method will return null. If you'd prefer an exception be thrown, you may use the findOrFail method:

Form::findOrFail('postbox');

Get all forms from your site

Form::all()

Get submissions to a form by its handle

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

The ->submissions() method will return a Collection of form submissions. You can use the Form Submissions repository if you need to query form submissions further.

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

shipment-container
HR: Section
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →