$formsaddForm()

Add a new form with the given name

Versions of FormBuilder prior to 0.5.7 should instead use the $forms->addNew() method, which works exactly the same as this one.

If you want to hook this method, hook the $forms->addNew() method instead, as this method also calls it.

Available since version 0.5.7.

Example

// Example of adding a new form
$form = $forms->addForm('contact');
$form->addField('first_name', 'Text', 'First name');
$form->addField('last_name', 'Text', 'Last name');
$form->addField('email', 'Email', 'Your email');
$form->addField('message', 'Textarea', 'Message');
$form->save();

Usage

$formBuilderForm = $forms->addForm(string $formName);

Arguments

NameType(s)Description
$formNamestring

Form name using characters: -_a-z0-9

Return value

Exceptions

Method can throw exceptions on error:

  • FormBuilderException - if given form name already exists or invalid form name


$forms methods and properties

API reference based on ProcessWire core version 3.0.251