FormBuilder: Entries
The FormBuilderEntries class provides methods for getting, finding, adding, updating and deleting submitted form entries.
You can get a FormBuilderEntries
instance either from a FormBuilderForm
object, or from a FormBuilderProcessor
object:
// get entries from FormBuilderForm
$form = $forms->load('form-name'); // FormBuilderForm
$entries = $form->entries(); // FormBuilderEntries
// get entries from FormBuilderProcessor
$processor = $form->processor(); // FormBuilderProcessor
$entries = $processor->entries(); // FormBuilderEntries
// find entries
foreach($entries->find("first_name=Ryan") as $entry) {
$li = "$entry[first_name] $entry[last_name]: $entry[email]";
$li = $sanitizer->entities($li);
echo "<li>$li</li>";
}
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the FormBuilderEntries
class also inherits all the methods and properties of: Wire.
Retrieval
Name | Return | Summary | |
---|---|---|---|
$entries->find() $entries->find($selectorString) $entries->find($selectorString, array $options = []) | array | Find form entries by selector string | |
$entries->getById() $entries->getById(int $id) $entries->getById(int $id, string $col = '') | bool array | Get a form entry by ID | |
$entries->getByName() $entries->getByName(string $name) $entries->getByName(string $name, string $col = '') | bool array | Get a form entry by name | |
$entries->getBySelector() $entries->getBySelector($selectorString) $entries->getBySelector($selectorString) | null array | Get a single form entry array by selector string, or null if not found | |
$entries->getForm() $entries->getForm() $entries->getForm() | FormBuilderForm | Get the current FormBuilderForm that these entries are for | |
$entries->getLastEntryDate() $entries->getLastEntryDate() $entries->getLastEntryDate(bool $reverse = false) | string | Get date of last entry | |
$entries->getTotal() $entries->getTotal() $entries->getTotal() | int | Return total number of entries |
Manipulation
Name | Return | Summary | |
---|---|---|---|
$entries->delete() $entries->delete(int $id) $entries->delete(int $id) | int bool | Delete a form entry by ID | |
$entries->deleteAll() $entries->deleteAll() $entries->deleteAll() | bool | Delete all entries for this form | |
$entries->deleteOlderThan() $entries->deleteOlderThan(int $age) $entries->deleteOlderThan(int $age, string $ageType = 'DAYS', string $dateColumn = 'created', $flags = null) | int | Delete entries older than a given number of days (or indicated age type) | |
$entries->save() $entries->save(array $entry) $entries->save(array $entry) | int bool | Save the given form entry | |
$entries->saveField() $entries->saveField(int $id, string $name, mixed $value) $entries->saveField(int $id, string $name, mixed $value) | bool | Update a single form field value for an existing entry |
Import export
Name | Return | Summary | |
---|---|---|---|
$entries->exportCSV() $entries->exportCSV(FormBuilderForm $form, string $selectorString) $entries->exportCSV(FormBuilderForm $form, string $selectorString, array $options = []) | None | Works like find() except that it exports and sends a CSV file to output | |
$entries->importCSV() $entries->importCSV(string $filename) $entries->importCSV(string $filename, array $options = []) | array | Import CSV file |
For hooks
These methods are only useful for hooking and should not be called directly.
Name | Return | Summary | |
---|---|---|---|
$entries->deleted() $entries->deleted(array $entryIDs) $entries->deleted(array $entryIDs) | None | Hook called after one or more entry IDs have been deleted | |
$entries->exportCSV_formatValueArray() $entries->exportCSV_formatValueArray(FormBuilderForm $form, $field, array $value) $entries->exportCSV_formatValueArray(FormBuilderForm $form, $field, array $value) | string | Format array value for output in CSV column |
Files
Name | Return | Summary | |
---|---|---|---|
$entries->getFilesPath() $entries->getFilesPath() $entries->getFilesPath(int $entryID = 0, bool $create = true, int $formID = 0) | string | Return the path that may be used by entries | |
$entries->hasFilesPath() $entries->hasFilesPath() $entries->hasFilesPath(int $entryID = 0, int $formID = 0) | bool | Does a files path exist for form/entry? |
Flags
Name | Return | Summary | |
---|---|---|---|
$entries->addEntryFlag() $entries->addEntryFlag(array $entry, $flag) $entries->addEntryFlag(array $entry, $flag) | array | Add flag to entry (in memory only) and return entry | |
FormBuilderEntries::flagPartial const | 1 | Flag indicates entry is a partial entry | |
FormBuilderEntries::flagSpam const | 16 | Flag indicates entry is spam | |
$entries->removeEntryFlag() $entries->removeEntryFlag(array $entry, $flag) $entries->removeEntryFlag(array $entry, $flag) | array | Remove flag to entry (in memory only) and return entry |
Additional methods and properties
In addition to the methods and properties above, FormBuilderEntries also inherits the methods and properties of these classes:
API reference based on ProcessWire core version 3.0.251