FormBuilder / $forms

FormBuilder is the ProcessWire Form Builder module API

When the module is installed, ProcessWire provides it as the $forms API variable.

$form = $forms->load('contact');
echo $forms->render('contact');

For hook-based customization of rendered and submitted forms, see API-HOOKS.md. Most form lifecycle customization happens through FormBuilderProcessor hooks.

Expand all      API reference

Getting Forms

load($id)

Load one form by name or ID.

$form = $forms->load('contact');

Returns FormBuilderForm|null.

loadAll()

Load all forms, indexed by form name.

foreach($forms->loadAll() as $name => $form) {
  echo $name;
}

Returns FormBuilderForm[].

getFormName($id)

Get the form name for a form ID, FormBuilderForm, or InputfieldForm.

Returns string.

getFormNames($id = 0)

Get all form names indexed by form ID, or pass an ID to get one name.

Returns array|string.

isForm($id)

Return true when the given form name or ID identifies an existing form.

Returns bool.

Creating And Saving Forms

addForm($formName)

Create a new form object. Call save() when you are ready to persist it.

$form = $forms->addForm('contact');
$form->addField('email', 'Email', 'Your email');
$form->save();

Returns FormBuilderForm.

save(FormBuilderForm $form)

Save a form.

$forms->save($form);

Returns bool.

delete(FormBuilderForm $form)

Delete a form.

Returns bool.

clone(FormBuilderForm $form, $newFormName = '')

Clone a form to a new form.

Returns FormBuilderForm.

Rendering Forms

render($form, $vars = array())

Render a form by name, ID, or FormBuilderForm. This returns a FormBuilderRender object containing markup plus any styles/scripts collected for the render. Also known as: Embed method C

$form = $forms->render('contact');
echo $form->styles;
echo $form->scripts;
echo $form; // string value is form markup

Example of using the $vars argument to pre-populate form:

$form = $forms->render('contact', [
    'first_name' => 'Ryan',
    'last_name' => 'Cramer',
    'email'=> 'ryan@processwire.com',
]);
echo $form->styles . $form->scripts . $form;

Example of rendering with ProcessWire WireMarkupRegions to populate HTML containing elements:

$form = $forms->render('contact');
echo "
    <head pw-append>$form->styles</head>
    <body pw-append>$form->scripts</body>
    <div id='content' pw-append>$form</div>
";

Returns FormBuilderRender.

embed($formName, array $vars = null)

Return embed markup for embed method A or B. This makes the form render in an <iframe> rendered by the /form-builder/ page using the /site/templates/form-builder.php template file:

// render form 
echo $forms->embed('contact');

// with variables pre-populated
echo $forms->embed('contact', [
    'first_name' => 'Ryan',
    'last_name' => 'Cramer',
    'email' => 'ryan@processwire.com'
]); 
Entries

Entries are the results collected from user-submitted forms.

getEntry($entryID, $form = 0)

Get a submitted entry by ID. Entry IDs are unique across all forms, so the form can usually be inferred from $entryID. Pass $form when you want to require that the entry belongs to a specific form.

Returns array|false.

saveEntry(array $entry, $form = 0)

Save an entry array. Existing entries should include their id in the $entry array; new entries omit it.

Returns int|false. On success it returns the saved entry ID.

findEntries($keywords, $operator = '*=', $form = 0)

Search entries by keywords. If no $form is given, all forms will be searched. For selector-based queries, use $form->entries()->find($selector) where $form is a FormBuilderForm object.

Returns array[].

countEntries($id)

Return the number of entries for a form name, ID, or FormBuilderForm.

Returns int.

Export And Import

exportJSON($form)

Return the JSON schema for a form name, ID, or FormBuilderForm.

Returns string.

importJSON($form, $json)

Import JSON schema data into a form name, ID, or FormBuilderForm.

Returns bool.

Files

getFilesPath($tmp = false, $create = true)

Return the filesystem path FormBuilder uses for uploaded files.

Returns string.

getFileKey($formID, $entryID, $filename)

Generate a portable key for a file belonging to a form and entry. A portable key is a string that can be used to retrieve the file and is safe to include in URLs. It is referred to as "key" in other file methods.

Returns string|false.

getFileFromKey($key)

Resolve a file key back to a filename.

Returns string|false.

getFileURL($formID, $entryID, $filename)

Return a URL where a stored file can be viewed.

Returns string|false.

viewFile($key)

Send a stored file to the browser using a file key.

Returns void. Throws Wire404Exception if the file cannot be found or viewed.

Access And Tools

hasPermission($name, $form)

Return whether the current user has the named FormBuilder permission for a form.

Returns bool.

isReservedName($name)

Return whether a name is reserved and should not be used for a form or field.

Returns bool.

form($form, $throw = true)

Resolve a form name, ID, or FormBuilderForm to a FormBuilderForm object. When $throw is true, invalid values throw a FormBuilderException; when false, invalid values return false.

Returns FormBuilderForm|false.

formID($value, $throw = true)

Resolve a form name, ID, or FormBuilderForm to a form ID.

Returns int.

formName($value, $throw = true)

Resolve a form name, ID, or FormBuilderForm to a form name.

Returns string.

entryToForm($entry)

Resolve an entry array or entry ID to the FormBuilderForm it belongs to.

Returns FormBuilderForm|false.

getFramework(FormBuilderForm $form)

Return the configured FormBuilderFramework for a form, when available.

Returns FormBuilderFramework|null.

count()

Return the total number of forms in FormBuilder.

Returns int.

themesPath($theme = '')

Return the filesystem path for FormBuilder themes, optionally including a theme name.

Returns string.

frameworksPath()

Return the filesystem path for FormBuilder frameworks.

Returns string.

themesURL($theme = '')

Return the URL for FormBuilder themes, optionally including a theme name.

Returns string.

frameworksURL()

Return the URL for FormBuilder frameworks.

Returns string.

formLog($form, $str)

Record a FormBuilder log entry.

Returns void.

Examples

Update A Form Setting

$fbForm = $forms->load('contact');
$fbForm->successMessage = 'Thanks, we received your message.';
$fbForm->save();

Add And Remove Fields

$fbForm = $forms->load('contact');
$fbForm->addField('phone', 'Text', 'Phone', [
  'required' => true,
  'columnWidth' => 50,
]);
$fbForm->removeField('old_field');
$fbForm->save();

Find Entries With A Selector

$fbForm = $forms->load('contact');
$entries = $fbForm->entries()->find('created>=2026-01-01, sort=-created, limit=10');

Save Or Update An Entry

$entryID = $forms->saveEntry([
  'first_name' => 'Ryan',
  'email' => 'ryan@example.com',
], 'contact');

$entry = $forms->getEntry($entryID);
$entry['email'] = 'new@example.com';
$forms->saveEntry($entry);

Export And Import A Form Schema

$json = $forms->exportJSON('contact');
$target = $forms->load('contact-copy');

if($target) {
  $forms->importJSON($target, $json);
}
FormBuilderForm

A FormBuilderForm represents one form, its settings, and its fields. FormBuilder often uses the variable $fbForm to represent a FormBuilderForm, at least when there is potential for confusion with InputfieldForm, which might also be represented by the variable name $form. The FormBuilderForm class extends the FormBuilderField class and also inherits its methods.

// Loading a form
$fbForm = $forms->load('contact');

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

// Updating a field
$field = $fbForm->getField('message');
$field->description = 'Please describe your needs';
$fbForm->save();

// Removing a field
$fbForm->removeField('last_name');
$fbForm->save();

// Convert to an InputfieldForm
$inputfields = $fbForm->getInputfield();

Properties

Core

PropertyTypeDescription
idintForm ID.
namestringForm name.
descriptionstringForm description.
mobilePxintMobile responsive breakpoint for this form, in pixels.
flagsintForm flags. See FormBuilderProcessor::formFlag* constants.
formFlagsintAlias of flags.
rolesarrayForm roles for access control.
themestringjQuery UI theme used by this form, if any.
frameworkstringHTML/CSS framework used by this form.
pluginActionsarrayNames of plugin actions enabled for this form.
numEntriesintNumber of submitted entries for this form.
lastEntryDatestringDate of last submitted form entry.
firstEntryDatestringDate of first submitted form entry.
numFieldsintNumber of fields in this form.

Flags And Settings

PropertyTypeDescription
saveFlagsintBitwise flags for save actions. See FormBuilderProcessor::saveFlag* constants.
allowPresetbool|intAllow preset field values from GET variables.
skipSessionKeybool|intDisable session tracking and CSRF protection.
useCookiesbool|intRemember form values in cookies.

Spam Protection

PropertyTypeDescription
honeypotstring|arrayField name, or names, to use as a honeypot.
spamWordsarray|nullWords that cause a submission to be treated as spam when spam words are enabled.
spamFlagsint|nullSpam handling flags. Common values include silent, verbose, and save-spam-entry behaviors.
akismetstringCSV data for Akismet configuration.

Entries

PropertyTypeDescription
listFieldsarrayField names to show in entries list by default.
entryDaysintMaximum days an entry may be saved in the system.
partialEntryTypeintStorage type for partial entries, where 0 is session and 1 is database.
partialEntryDaysintMaximum days an incomplete/partial entry may exist.
spamEntryDaysintMaximum days a spam entry may be saved.

Administrator Email

Settings for administrator email.

PropertyTypeDescription
emailTostringAdministrator email recipient address, addresses, or format string.
emailFromstringAdministrator email reply-to address, also used as from address when emailFrom2 is not specified.
emailFrom2stringAdministrator email from address when different from emailFrom.
emailSubjectstringAdministrator email subject line.

Auto-responder

Settings for auto-responder email.

PropertyTypeDescription
responderTostringField containing the submitter email address, or CSV string for multiple fields.
responderFromstringAuto-responder from address.
responderFromNamestringAuto-responder from name.
responderReplyTostringAuto-responder reply-to address.
responderSubjectstringAuto-responder subject.
responderBodystringAuto-responder body.

Duplicate Submission

Settings for sending a duplicate copy of the form submission to another URL.

PropertyTypeDescription
action2stringDuplicate submission URL.
action2_addstringFields to add to duplicate submission, in textarea format.
action2_removestringNewline-separated field names to remove from duplicate submission.
action2_renamestringField renames for duplicate submission, in key=value format with one per line.

Output

PropertyTypeDescription
submitTextstringDefault submit button text.
nextTextstringDefault next button text for paginated forms.
backTextstringDefault back button text for paginated forms.
successMessagestringMessage displayed after successful form submission.
errorMessagestringMessage displayed when the form has errors.
submitNotifybool|intNotify user if they attempt to leave after changing the form without submitting.

Save To Pages

These settings apply only if the form is configured to save form submissions to pages.

PropertyTypeDescription
savePageTemplateintTemplate ID for pages created from entries.
savePageParentintParent page ID for pages created from entries.
savePageFieldsarrayMap of page field IDs to form field names.
savePageSubfieldsstringMulti-line mapping of form_field=page_field or form_field=page_field.subfield.
savePageStatusintPage status used for newly created pages.

Google Sheets

To populate a Google Sheet you must have the GoogleClientAPI module installed.

PropertyTypeDescription
googleSpreadsheetUrlstring|nullFull URL of Google Sheet to populate with entries.
googleSpreadsheetFieldsarray|nullForm field names to populate into Google Sheet, in order.
googleSheetsResponseFieldstringOptional field name to populate with the Google Sheets response.

Pagination

PropertyTypeDescription
hLevelintHeadline level used above paginated forms, or 0 for off.
showNavintSelect-nav position for paginations, or 0 for off.

addField($name, $type = '', $label = '', array $options = [])

Create and append a field to the form. $type is the Inputfield class name without the Inputfield prefix, such as Text, Email, Textarea, or Select.

Returns FormBuilderField. The returned field is already added to the form, but the form is not saved until you call $fbForm->save().

$fbForm->addField('first_name', 'Text', 'First name', [
  'required' => true,
  'columnWidth' => 50,
]);

add(FormBuilderField $child)

Append an existing FormBuilderForm or FormBuilderField as a child field element.

Returns FormBuilderForm.

removeField($key)

Remove a field by object or name.

Returns FormBuilderForm.

save()

Save this form.

Returns bool.

render()

Render and/or process this form using its FormBuilderProcessor.

Returns string.

processor($options = array())

Return the FormBuilderProcessor for this form. Pass ['reset' => true] to force a new instance.

Returns FormBuilderProcessor.

entries()

Return the FormBuilderEntries manager for this form.

Returns FormBuilderEntries.

isSubmitted()

Return whether the form has been submitted in the current request.

Returns bool.

getErrors()

Return form processing errors.

Returns array.

hasPermission($name)

Return whether the current user has a permission for this form.

Returns bool.

getFramework()

Return the HTML/CSS framework used by this form.

Returns FormBuilderFramework|null.

getPageBreakFields()

Return FormBuilderPageBreak fields indexed by page number.

Returns FormBuilderField[].

getNumPaginations()

Return the number of paginations in the form.

Returns int.

hasField($name)

Return whether this form has a field by name.

Returns bool.

getField($name)

Get a field by name from anywhere in the form.

Returns FormBuilderField|null.

getFieldByName($name)

Alias of getField($name).

Returns FormBuilderField|null.

exists($name)

Return whether a field exists in the form.

Returns bool.

children()

Return direct child fields. Use getChildrenFlat() when you need nested fields too.

Returns FormBuilderField[].

getChildrenFlat(array $options = array())

Return all fields as a flat array indexed by field name.

Returns FormBuilderField[].

getInputfield(array $options = array())

Create a new InputfieldForm from this form configuration.

Returns InputfieldForm.

Flags (bitwise)

By default the flag methods operate on the FormBuilderForm $flags property. See the FormBuilderProcessor class formFlag* constants. The flag methods below also include a $property argument where you can optionally substitute saveFlags (for save action flags) or spamFlags (for spam action flags). See the corresponding saveFlag* or spamFlag* constants in the FormBuilderProcessor class.

hasFlag($flag, $property = 'flags')

Return whether a form flag is present.

For this method and the two below:

Returns int.

addFlag($flag, $property = 'flags')

Add a form flag in memory.

Returns void.

removeFlag($flag, $property = 'flags')

Remove a form flag in memory.

Returns void.

FormBuilderField

FormBuilderField represents one field in a FormBuilderForm. It also provides the base tree methods used by FormBuilderForm.

setName($name)

Set and sanitize the field name.

Returns FormBuilderData.

fbForm()

Return the root FormBuilderForm for this field.

Returns FormBuilderForm.

getSetting($key)

Get a setting directly from this field.

Returns mixed|null.

setArray(array $data)

Populate this field from array data, including nested children data.

Returns void.

getArray()

Return this field and its children as array data.

Returns array.

add(FormBuilderField $child)

Append a child field.

Returns FormBuilderField.

addField($name, $type = '', $label = '', array $options = [])

Create and append a child field.

Returns FormBuilderField.

remove($key)

Remove a child field by object or name.

Returns FormBuilderField.

children()

Return direct children.

Returns FormBuilderField[].

getChildrenFlat(array $options = array())

Return all descendant fields as a flat array.

Returns FormBuilderField[].

child($name)

Return a direct child by name.

Returns FormBuilderField|null.

getFieldByName($name)

Return a field by name from anywhere in the form tree.

Returns FormBuilderField|null.

getInputfield(array $options = array())

Create a new ProcessWire Inputfield instance from this field configuration.

Returns Inputfield.

FormBuilderEntries

FormBuilderEntries manages submitted entry data for one form.

$entries = $forms->load('contact')->entries();
$latest = $entries->find('sort=-created, limit=10');

Note that an individual form entry is represented by a regular PHP associative array.

find($selectorString, array $options = array())

Find entries with a selector string.

Returns array[], where each item is an associative array representing one entry.

getById($id, $col = '')

Get an entry by ID, optionally returning one database column.

Returns array|mixed|false. Returns an entry array when $col is omitted, the requested column value when $col is specified, or false when no entry matches.

getByName($name, $col = '')

Get an entry by its entry name string.

Returns array|mixed|false. Returns an entry array when $col is omitted, the requested column value when $col is specified, or false when no entry matches.

getBySelector($selectorString)

Get the first matching entry for a selector string.

Returns array|null.

importCSV($filename, array $options = array())

Import entries from a CSV file.

Returns array with import counts, skipped/failed line numbers, and warnings.

exportCSV(FormBuilderForm $form, $selectorString, array $options = array())

Export matching entries as CSV and send the file to output.

Returns never; this method sends output and exits.

save(array $entry)

Save a new or existing entry. Existing entries should include id.

Returns int|bool. On success it returns the entry ID; on failure it returns false.

saveField($id, $name, $value)

Update one field value for an existing entry.

Returns bool.

delete($id)

Delete one entry by ID.

Returns int|bool. On success it returns the deleted entry ID; on failure it returns false.

deleteAll()

Delete all entries for the form.

Returns bool.

deleteOlderThan($age, $ageType = 'DAYS', $dateColumn = 'created', $flags = null)

Delete entries older than a given age.

Returns int, the number of entries deleted.

getTotal()

Return the total number of entries for the form.

Returns int.

getLastEntryDate($reverse = false)

Return the newest entry date, or the first entry date when $reverse is true.

Returns string, or blank string when there are no entries.

getFilesPath($entryID = 0, $create = true, $formID = 0)

Return the files path for the form or a specific entry.

Returns string.

hasFilesPath($entryID = 0, $formID = 0)

Return whether a files path exists.

Returns bool.

getForm()

Return the FormBuilderForm these entries belong to.

Returns FormBuilderForm.

addEntryFlag(array $entry, $flag)

Add an entry flag in memory and return the modified entry array.

Returns array.

removeEntryFlag(array $entry, $flag)

Remove an entry flag in memory and return the modified entry array.

Returns array.

validEntryName($name)

Validate an entry name string, returning the name or an empty string.

Returns string.

isReservedProperty($property)

Return whether an entry property name is reserved for system use.

Returns bool.

FormBuilderEmail

FormBuilderEmail prepares and sends administrator and auto-responder email messages. It is most often customized from FormBuilderProcessor email hooks.

Properties

PropertyTypeDescription
tostringRecipient email address, addresses, or conditional recipient rules.
fromstringFrom email address.
fromNamestringFrom name.
replyTostringReply-to email address or field name to pull from submitted form data.
subjectstringEmail subject.
bodystringEmail body in HTML.

setRawFormData(array $data)

Set raw submitted form data.

Returns void.

getRawFormData()

Return raw submitted form data.

Returns array.

setMailer($mailerName)

Set the WireMail module name to use. Use WireMail for native PHP mail behavior or leave blank for auto-detect.

Returns void.

setWireMail(WireMail $wireMail)

Provide a specific WireMail instance.

Returns void.

getWireMail()

Return the WireMail instance that will be used.

Returns WireMail.

addFileAttachment($filename)

Add a file attachment to the email when the WireMail implementation supports attachments.

Returns bool. Returns true when the file exists and was queued as an attachment, or false when the file does not exist.

send($template = 'email')

Send the email using the named email template.

Returns bool|int. Returns 0 when there are no recipients; otherwise returns the result from the mailer.

setSkipFieldName($fieldName)

Skip a field by name when rendering the email body.

Returns FormBuilderEmail.

setValues(array $values, $entityEncode = true)

Add values to the email template data.

Returns void.

setLabels(array $labels, $entityEncode = true)

Add labels to the email template data.

Returns void.

Notes
  • Changes to a FormBuilderForm or its FormBuilderField objects are not saved until you call $fbForm->save() or $forms->save($fbForm).
  • FormBuilderForm is FormBuilder's configuration object for a form. ProcessWire's InputfieldForm is the rendered/processable form object produced from that configuration.
  • Individual submitted entries are regular PHP associative arrays, not entry objects.
  • Methods that send files to output, such as FormBuilderEntries::exportCSV() and FormBuilder::viewFile(), end the request after sending output.
  • Hookable methods and lifecycle customization examples are documented separately in API-HOOKS.md.

API reference: methods, properties, hooks, constants

This class also contains the most commonly hooked methods in FormBuilder. Please note that this is a class you typically wouldn't call methods from. Instead, most interactions with this class are by hooking its methods.

$forms->addHook('FormBuilderProcessor::methodName', function(HookEvent $e) {
  $pro = $event->object; // get FormBuilderProcessor
  // ...hook code...
});

// Example
$forms->addHookBefore('FormBuilderProcessor::renderReady', function(HookEvent $event) {
  $pro = $event->object; // FormBuilderProcessor instance
  $form = $pro->getInputfieldForm();
  if($pro->formName == 'foo') {
    // do something for form named "foo"
  } else if($pro->formName == 'bar-baz') {
    // do something else for form named "bar-baz"
  }
}); 

Where to place FormBuilder hooks?

Hooks can be added anywhere before a form is rendered, for instance in a template file. But depending on the embed method and version, these are common locations:

FileDescription
/site/ready.phpWorks anywhere and in any version
/site/templates/FormBuilder/hooks.phpRequires FormBuilder 0.5.7 or newer
/site/templates/FormBuilder/hooks-formName.phpRequires FormBuilder 0.5.7 and newer
/site/templates/admin.phpUseful if hooks needed in admin only, works in any version
/site/templates/_init.phpWorks only if already using an _init.php, hooks affect front-end only
/site/templates/form-builder.phpPlacing hooks at the top of this file targets just embed methods A and B
/site/templates/form-builder.incThe original FormBuilder hooks file, supported by all versions

Using the hooks.php or hooks-formName.php (replacing formName with actual form name) is preferable when available, as they are loaded only when a form will be rendered or processed.

Processor plugin modules

You can use or create FormBuilderProcessorAction modules to automatically plug-in to any part of the form life cycle. This is ideal if you want to add hook-like functionality that can easily be shared, configured and enabled/disabled on a per-form basis.


Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the FormBuilderProcessor class also inherits all the methods and properties of: WireData and Wire.

Show $var?     Show args?       Only hookable?    

Entries

NameReturnSummary 
$processor->addEntryReady(array $data, InputfieldForm $form)
array

Hook called when new entry is about to be added

$processor->addedEntry(array $data, InputfieldForm $form)
array

Hook called after a new entry has been added

$processor->entries()
FormBuilderEntries

Get the FormBuilderEntries object for the current form

 
$processor->formToEntry(InputfieldForm $form)
array

Converts the submitted InputfieldForm object to an entry data array

$processor->getEntry()
array null

Get the current form entry, or null if not present

 
$processor->getEntryID()
int

Get the current entry ID, or 0 if not present

 
$processor->loadEntry($entryID)
InputfieldForm

Load entry by ID or name and populate to form

 
$processor->populate(array $data)
InputfieldForm

Populate the form with the key=value data (or form entry) given in the array

$processor->saveEntry(array $data)
int

Save or update a form entry

$processor->setEntry(array $data)
None

Set current entry data

 
$processor->updateEntryReady(array $data, InputfieldForm $form)
array

Hook called when an existing entry is about to be updated

$processor->updatedEntry(array $data, InputfieldForm $form)
array

Hook called when an existing entry has been added

Pages

NameReturnSummary 
$processor->allowSavePageField(Page $page, string $pageFieldName, string $formFieldName, string $value, array $entry)
bool

Returns true if given value should be saved, false if not (for hooks)

$processor->getSavePage()
NullPage Page

Get page that was saved

 
$processor->savePage(array $data)
Page null

Save the form entry to a Page

$processor->savePageAdjustName bool int Adjust page name as needed to ensure it is unique?
DEFAULT: true
 
$processor->savePageCheckName(Page $page)
bool

Check and update page name as needed for uniqueness (for hooks)

$processor->savePageDone(Page $page, array $data, bool $isNew, $onlyFields)
array

Hook called right after a page is saved

$processor->savePageFields array array of [ 'processwire_field_id' => 'form_field_name' ] to map page fields to form fields  
$processor->savePageFileField(Page $page, Field $field, array $filenames, string $formFieldName)
int

Save an individual files field to a Page (for hooks)

$processor->savePageInit(array $data, $status, $onlyFields)
array

Get settings for saving a page (for hooks)

$processor->savePageParent string ID of parent page for newly created pages  
$processor->savePageReady(Page $page, array $data)
None

Hook called right before a Page is about to be saved

$processor->savePageStatus int status of saved page (0 = don't save page now)  
$processor->savePageSubfields string Newline separated string in format: form_field_name=page_field_name.subfield  
$processor->savePageTemplate string Name of template for newly created pages  

Email

NameReturnSummary 
$processor->emailForm(InputfieldForm $form, array $data)
bool int

Email the form result to the administrator(s)

$processor->emailFormPopulateSkipFields(FormBuilderEmail $email, InputfieldForm $form)
None

Hookable method for populating fields that should be skipped in an email

$processor->emailFormReady(InputfieldForm $form, FormBuilderEmail $email)
bool

Hook called before email is sent to administrator

$processor->emailFrom string Email address (or field name where it resides) to use as the reply-to address for the email.  
$processor->emailFrom2 string Email FROM address, if different the one specified in module settings and reply-to address.  
$processor->emailFromName string Email from name  
$processor->emailSubject string subject of email that gets sent  
$processor->emailTo string Email address to send form submissions to, may also be multiple (1 per line) or conditional (1 condition per line)  
$processor->mailer string Name of WireMail module to use for sending email, 'WireMail' for native PHP mail(), or blank for auto-detect.  

Auto responder

NameReturnSummary 
$processor->emailFormResponder(InputfieldForm $form, array $data)
bool

Email the form result to the sender (auto-responder)

$processor->emailFormResponderReady(InputfieldForm $form, FormBuilderEmail $email)
bool

Hook called before email is sent to autoresponder, see details for example

$processor->responderBody string Body for the responder email  
$processor->responderFrom string Email address that the responder email should be from  
$processor->responderFromName string Name responder should be from  
$processor->responderReplyTo string Responder reply-to address  
$processor->responderSubject string Subject line for the responder email  
$processor->responderTo string field name (not email address) that WILL contain the submittor's email address (where the responder should be sent). CSV string for multiple.  

Spam

NameReturnSummary 
$processor->akismet string CSV string containing field names of: "name,email,content" (in that order)  
$processor->honeypot string array name of field that, when populated, invalidates the form submission (or array of them)  
$processor->isSpam()
bool string

Returns name of triggered spam filter when entry detected as spam

 
$processor->processInputIsSpam(InputfieldForm $form, bool $processed)
string

Does given processed form contain spam?

$processor->processInputSpammed(InputfieldForm $form, string $spamType)
None

Hook called when processInput fails due to being spammed

$processor->spamFlags int Spam flags  
$processor->spamTimer int Time required between render and submit for form to be considered valid  
$processor->spamWords array Keywords that flag a form submission as spam.  
$processor->turingTest array array containing list of field names and required answers  

Other actions

NameReturnSummary 
$processor->action2 string URL to send duplicate submission to  
$processor->action2_add array array of name=value to add to duplicate submission  
$processor->action2_remove array array of field names to remove from duplicate submission  
$processor->action2_rename array array of field names rename before duplicate submission  
$processor->googleSheetsResponseField string Name of field to poulate with Google Sheets response (which indicates row and column)  
$processor->googleSpreadsheetFields array  
$processor->googleSpreadsheetUrl string  
$processor->postAction2(array $data)
bool

Post a duplicate copy of the form submission/entry to another URL

$processor->postAction2Ready(WireHttp $http, array $data, string $method, string $url, array $headers)
bool string

Called right before we send a duplicate copy to another URL

$processor->saveGoogleSheets(InputfieldForm $form, array $data)
bool

Save to Google Sheets

$processor->saveGoogleSheetsReady(GoogleSheets $sheets, array $row, array $data)
array

Hook called before spreadsheet row saved, can optionally modify $event->return (spreadsheet row)

Output

NameReturnSummary 
$processor->appendMarkup(string $markup)
None

Add markup to append to the form

 
$processor->dupMessage string message to display when form is already submitted / duplicate submission  
$processor->errorMessage string message to display when a form error occurred  
$processor->renderError(string $error)
string

Render an error message into markup

$processor->renderSuccess(string $message)
string

Render the given success message for output

$processor->renderSuccessMessage(string $message)
string

Render a success message

$processor->renderSuccessRedirect(string $url)
string

Render a success redirect

$processor->submitText string text that appears on the submit button  
$processor->successMessage string message to display on successful form submission, assuming no successUrl was set  
$processor->successUrl string URL to redirect to on successful form submission  

Success

NameReturnSummary 
$processor->formSubmitSuccess(InputfieldForm $form)
None

Called upon successful form submission

$processor->renderSuccess(string $message)
string

Render the given success message for output

$processor->renderSuccessMessage(string $message)
string

Render a success message

$processor->renderSuccessRedirect(string $url)
string

Render a success redirect

$processor->successMessage string message to display on successful form submission, assuming no successUrl was set  
$processor->successUrl string URL to redirect to on successful form submission  

Errors

NameReturnSummary 
$processor->addError(string $text)
None

Add an error message that is shown to the user

 
$processor->addWarning(string $text)
None

Add a warning that can be shown to user but does not prevent form submission

 
$processor->adminError(string $text)
None

Add an error message that is ony shown if user has form-builder permission

 
$processor->clearErrors()
None

Clear all errors and warnings

 
$processor->errorMessage string message to display when a form error occurred  
$processor->formSubmitError(InputfieldForm $form, array $errors)
None

Called upon a form submission error, for hooks to listen to.

$processor->formSubmitInvalid(InputfieldForm $form, array $errors)
None

Called when an invalid form submission is received that prevented it from being processed

$processor->getErrors()
array

Return an array of errors that occurred (strings)

 
$processor->getWarnings()
array

Return an array of warnings that occurred (strings)

 
$processor->hasErrors()
bool

Are there any errors present on form or in this processor?

 
$processor->renderError(string $error)
string

Render an error message into markup

$processor->renderErrors()
string

Render the given error messages for output

$processor->renderErrorsReady(array $errors)
array

Called when errors about to be rendered

Submit

NameReturnSummary 
$processor->getSubmitType()
bool int null

Get the form submit type

 
$processor->getValues()
array

Get an array of all values from this form

 
$processor->isSpam()
bool string

Returns name of triggered spam filter when entry detected as spam

 
$processor->isSubmitted()
bool

Was the form successfully submitted? (for public API)

 
$processor->setSubmitType($submitType)
None

Set the form submit type

 

Settings

NameReturnSummary 
$processor->allowPreset bool allow form field values to be pre-set from GET variables?  
$processor->formName string name of the form  
$processor->framework string Name of form framework to use  
$processor->id int Form ID number  
$processor->pluginActions array Array of FormBuilderProcessorAction module names used as plugins to add form processing actions  
$processor->saveFlags int Flags for saving form submission
DEFAULT: self::saveFlagsDB
 
$processor->showHidden bool Show input[type=hidden] as type=text instead? Option may only be modified in construct $options.
DEFAULT: false
 
$processor->skipSessionKey bool Require a unique session key for each form submission (for security)  
$processor->useCookies bool Remember input values?  
$processor->validateNumFields bool Validate quantity of fields present in form as part of the _submitKey?  

Save flags

Constants used to populate the $saveFlags property, which dictates what actions to take with submitted forms. There can be multiple saveFlags so they should be applied in bitwise fashion.

NameReturnSummary 
FormBuilderProcessor::saveFlagAction2 const4Used when form entries should have a duplicate copy sent to a 3rd party service 
FormBuilderProcessor::saveFlagDB const1Used when form entries should be saved to database 
FormBuilderProcessor::saveFlagEmail const2Used when form entries should be sent via email to administrator 
FormBuilderProcessor::saveFlagExternal const16Used when the form should submit somewhere else (rendering all other save options invalid) 
FormBuilderProcessor::saveFlagFilterSpam const32Used when form submissions should be screened for spam 
FormBuilderProcessor::saveFlagGoogleSheets const128Used when form submissions should also save to Google Sheets 
FormBuilderProcessor::saveFlagPage const8Used when entries should be saved to new pages 
FormBuilderProcessor::saveFlagResponder const64Used when form submissions should include an auto-responder email 
FormBuilderProcessor::saveFlagsLabels()
array string

Get array (or csv string) of text labels for given saveFlags

 

Form flags

Constants used to populate the $formFlags property, which maintains form toggle settings. There can be multiple saveFlags so they should be applied in bitwise fashion.

NameReturnSummary 
FormBuilderProcessor::formFlagDisabled const4Used when form is disabled for accepting new entries 
FormBuilderProcessor::formFlagEditLinks const1024Used when edit links should be shown in form preview 0.5.7+  
FormBuilderProcessor::formFlagEmailFiles const256Used when uploaded files should be included as email attachments 
FormBuilderProcessor::formFlagEmailSubjectId const512Used when entry ID should be included in email subjects 
FormBuilderProcessor::formFlagInclude const2Used when for is intended as an include for other forms 
FormBuilderProcessor::formFlagNoModal const1Used when modal window for admin/editing should be disabled 

Spam flags

NameReturnSummary 
FormBuilderProcessor::spamFlagEntry const8Specifies that we should still save spam entries but flag them as spam 
FormBuilderProcessor::spamFlagNone const0Specifies that default reporting should be used for spam 
FormBuilderProcessor::spamFlagSilent const2Specifies that spam entries should be silently discarded 
FormBuilderProcessor::spamFlagVerbose const4Specifies that we should notify the persion submitting the form that spam was detected 

Additional methods and properties

In addition to the methods and properties above, FormBuilderProcessor also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.275