Form submissions are stored in the database and can be viewed, searched, exported, and processed.
Viewing Submissions
Admin Interface
Access submissions at:
/admin/forms/submissions- All submissions across all forms/admin/forms/{form}/submissions- Submissions for a specific form/admin/forms/{form}/submissions/{submission}- Single submission detail
Programmatically
use ArtisanPackUI\Forms\Models\FormSubmission;
// Get all submissions for a form
$submissions = FormSubmission::where('form_id', $formId)
->with('values', 'uploads')
->latest()
->paginate(20);
// Get a single submission
$submission = FormSubmission::with('values', 'uploads')->find($submissionId);
// Access field values
foreach ($submission->values as $value) {
echo $value->field_name . ': ' . $value->value;
}
Submission Data Structure
Each submission contains:
| Column | Description |
|---|---|
id |
Unique identifier |
form_id |
Related form ID |
submission_number |
Human-readable number |
ip_address |
Submitter's IP (if enabled) |
user_agent |
Browser user agent (if enabled) |
metadata |
JSON metadata |
created_at |
Submission timestamp |
Accessing Values
$submission = FormSubmission::with('values')->find($id);
// Get all values as array
$data = $submission->getFormData();
// ['name' => 'John', 'email' => 'john@example.com']
// Get specific value
$email = $submission->getValue('email');
// Get value with label
$values = $submission->getValuesWithLabels();
// ['label' => 'Email', 'name' => 'email', 'value' => 'john@example.com'](https://docs.artisanpackui.dev/documentation/forms/'label'-=>-'email',-'name'-=>-'email',-'value'-=>-'john@example.com')
Searching Submissions
Via Admin Interface
Use the search box to filter by:
- Field values
- Submission number
- Date range
- IP address
Programmatically
use ArtisanPackUI\Forms\Models\FormSubmission;
// Search by value
$submissions = FormSubmission::whereHas('values', function ($query) {
$query->where('value', 'like', '%john%');
})->get();
// Filter by date range
$submissions = FormSubmission::whereBetween('created_at', [
now()->subDays(7),
now(),
])->get();
// Filter by form and status
$submissions = FormSubmission::where('form_id', $formId)
->where('created_at', '>=', now()->subMonth())
->orderBy('created_at', 'desc')
->get();
Exporting Submissions
Via Admin Interface
- Go to the form's submissions page
- Click "Export"
- Choose format (CSV, Excel)
- Download the file
Spreadsheet Formulas
Since 1.6.0 the CSV export neutralises values a spreadsheet would run as a formula (CSV injection). A header or cell that starts with =, +, -, @, a tab or a carriage return gets a leading ', so Excel, LibreOffice and Google Sheets show it as text. Plain numbers such as -12.5 and phone numbers such as +15551234567 are left as they are. This runs after the ap.forms.exportHeaders and ap.forms.exportData filters, so values those filters add are covered too. The JSON export keeps raw values.
Programmatically
use ArtisanPackUI\Forms\Services\ExportService;
$exportService = app(ExportService::class);
// Export to CSV
$csvContent = $exportService->toCsv($form);
// Export to array
$data = $exportService->toArray($form);
// Export with date range
$data = $exportService->toArray($form, [
'start_date' => now()->subMonth(),
'end_date' => now(),
]);
Processing Submissions
Event Listeners
use ArtisanPackUI\Forms\Events\FormSubmitted;
class ProcessSubmission
{
public function handle(FormSubmitted $event): void
{
$form = $event->form;
$submission = $event->submission;
// Add to CRM
$this->crm->createContact([
'email' => $submission->getValue('email'),
'name' => $submission->getValue('name'),
]);
// Send to analytics
$this->analytics->track('form_submission', [
'form_id' => $form->id,
'form_name' => $form->name,
]);
}
}
Queue Processing
For heavy processing, queue the work:
class ProcessSubmission
{
public function handle(FormSubmitted $event): void
{
ProcessSubmissionJob::dispatch($event->submission);
}
}
Deleting Submissions
Single Submission
$submission = FormSubmission::find($id);
$submission->delete(); // Also deletes values and uploads
Bulk Delete
// Delete old submissions
FormSubmission::where('created_at', '<', now()->subYear())->delete();
// Or use the prune command
php artisan forms:prune-submissions
Automatic Pruning
Configure retention in config/artisanpack/forms.php:
'submissions' => [
'retention_days' => 365, // Delete after 1 year
],
Schedule the prune command:
// app/Console/Kernel.php or routes/console.php
Schedule::command('forms:prune-submissions')->daily();
Submission Numbers
Submissions are assigned sequential numbers based on the configured format:
'submissions' => [
'submission_number_format' => 'FORM-{year}-{sequence}',
// Results in: FORM-2024-0001, FORM-2024-0002, etc.
],
Available placeholders:
{year}- Current year{month}- Current month (2 digits){day}- Current day (2 digits){sequence}- Sequential number{form_id}- Form ID
Metadata
Store additional metadata with submissions:
use ArtisanPackUI\Forms\Services\SubmissionService;
$submissionService = app(SubmissionService::class);
$submission = $submissionService->create($form, $formData, [
'source' => 'landing-page',
'utm_source' => request('utm_source'),
'utm_campaign' => request('utm_campaign'),
]);
// Access metadata
$source = $submission->getMetadata('source');
$allMeta = $submission->metadata; // JSON decoded array
Next Steps
- Notifications - Email notifications for submissions
- File Uploads - Handling uploaded files
- API Reference - Detailed model and service documentation

