Form Builder
Create or edit forms and manage submitted entries.
The $forms
API variable is present if the commercial module FormBuilder is installed. Below are examples of embed method B and C. There are also embed methods A and D and instructions for
those can be found on the "Embed" tab when editing a form.
// Embed method B (in iframe)
echo $forms->embed('form-name');
// Embed method C (preferred method)
$form = $forms->render('form-name');
echo $form->styles; // preferably in <head>
echo $form->scripts; // preferably in <head> or before </body>
echo $form; // wherever form should output
Please see FormBuilderProcessor
for most of the hookable methods in FormBuilder, this is where most API usage and customization occurs. FormBuilderProcessorAction
modules can also be used to affect any part of a form’s life cycle.
More FormBuilder class reference pages
Class | Description |
---|---|
FormBuilderProcessor | Handles most parts of a form’s life cycle (rendering, processing). |
FormBuilderEntries | Manages the data submitted to a form, which we refer to as an entry. |
FormBuilderEmail | Handles the setup and distribution of administrator and auto-responder emails. |
FormBuilderForm | This class represents a form and maintains its configuration data and fields. |
FormBuilderProcessorAction | The full documented interface for FormBuilder plugin-in modules. |
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the FormBuilder
class also inherits all the methods and properties of: WireData and Wire.
Forms
Name | Return | Summary | |
---|---|---|---|
$forms->addForm() $forms->addForm(string $formName) $forms->addForm(string $formName) | FormBuilderForm | Add a new form with the given name | |
$forms->count() $forms->count() $forms->count() | int | Return number of forms here, per Countable interface | |
$forms->delete() $forms->delete(FormBuilderForm $form) $forms->delete(FormBuilderForm $form) | bool | Delete the given form | |
$forms->embed() $forms->embed($formName) $forms->embed($formName, array $vars = null) | string | Get the iframe embed markup for a given form (embed method A or B) | |
$forms->getFormNames() $forms->getFormNames() $forms->getFormNames(int $id = 0) | array string | Get names of all forms (indexed by form ID) | |
$forms->load() $forms->load($id) $forms->load($id) | FormBuilderForm array null | Load a form by ID or name | |
$forms->render() $forms->render($form) $forms->render($form, $vars = []) | FormBuilderRender | Render a form (embed method C) | |
$forms->save() $forms->save(FormBuilderForm $form) $forms->save(FormBuilderForm $form) | bool | Save the given form |
Entries
Name | Return | Summary | |
---|---|---|---|
$forms->countEntries() $forms->countEntries($id) $forms->countEntries($id) | int | Return the number of entries for the given form (object, name or ID) | |
$forms->findEntries() $forms->findEntries(string $keywords) $forms->findEntries(string $keywords, string $operator = '*=', $form = 0) | array | Find form entries across all forms (or on specific form if specified) | |
$forms->getEntry() $forms->getEntry(int $entryID) $forms->getEntry(int $entryID, $form = 0) | array bool | Get a form entry by ID | |
$forms->saveEntry() $forms->saveEntry(array $entry) $forms->saveEntry(array $entry, $form = 0) | bool int | Save a form entry |
Tools
Files
Name | Return | Summary | |
---|---|---|---|
$forms->getFileFromKey() $forms->getFileFromKey(string $key) $forms->getFileFromKey(string $key) | bool string | Retrieve a filename from a transportable key | |
$forms->getFileKey() $forms->getFileKey($formID, int $entryID, string $filename) $forms->getFileKey($formID, int $entryID, string $filename) | bool string | Generate a transportable key for the given filename within a form and entry | |
$forms->getFileURL() $forms->getFileURL($formID, int $entryID, string $filename) $forms->getFileURL($formID, int $entryID, string $filename) | bool string | Return a URL where the given file can be viewed | |
$forms->getFilesPath() $forms->getFilesPath() $forms->getFilesPath(bool $tmp = false, bool $create = true) | string | Return path that FormBuilder uses for storing files | |
$forms->viewFile() $forms->viewFile(string $key) $forms->viewFile(string $key) | None | Outputs the given file |
Access
Name | Return | Summary | |
---|---|---|---|
$forms->hasPermission() $forms->hasPermission(string $name, $form) $forms->hasPermission(string $name, $form) | bool | Check if the current user has the permission name for the given $form |
Export import
Name | Return | Summary | |
---|---|---|---|
$forms->exportJSON() $forms->exportJSON($form) $forms->exportJSON($form) | string | Return the JSON schema for the given form (name, ID or object) | |
$forms->importJSON() $forms->importJSON($form, string $json) $forms->importJSON($form, string $json) | bool | Import to form (name, ID or object) the given JSON schema |
For hooks
These methods are only useful for hooking and should not be called directly.
Name | Return | Summary | |
---|---|---|---|
$forms->addNew() $forms->addNew(string $formName) $forms->addNew(string $formName) | FormBuilderForm | Add a new form with the given name |
Additional methods and properties
In addition to the methods and properties above, FormBuilder also inherits the methods and properties of these classes:
API reference based on ProcessWire core version 3.0.251