Submit notification
Each form has an "After submitting" section, on its Notifications tab, and a
new form starts with a thank-you message there. Its outcomes are stored as one
list in submit_notifications, like the email notifications: each has an
id, conditions and conditionMatch, a type (content or url), and its
content, url and query.
- Content: a thank-you message shown after submit. It takes the same merge tags as an email notification, except the link to the submission in the panel, and they are filled in from the submission on submit.
- URL: a redirect target, a plain URL or a structured value a custom redirect field stores (see below), with an optional query string.
The last outcome has no conditions and is edited in place: what a form does by default. "A different outcome per answer" adds outcomes before it as cards, each under conditions on the answers, edited in a slide-over and ordered with "Move up" and "Move down". They are saved with the form.
On submit, the controller resolves the outcome through the form type
($form->getType()->resolveSubmitNotification($submission)): the first one
whose conditions the answers meet, skipping a kind the type does not allow
(hasRedirect(), hasNotificationMessage()). A URL goes through
FilamentFormBuilderPlugin::resolveRedirectUrl($outcome['url'], $form), a
message gets its tags filled in. When a URL is present it redirects, otherwise
the message is flashed back, both with a 303. getSubmitNotification($submission) returns the
outcome that applies, for a type that handles the response itself.
Passing field data via the query string
The URL branch has an optional query string, stored in the outcome's query.
Set the redirect_query config
flag to false to hide the field, or override hasSubmitNotificationQuery() on
a form type to drop it for that type alone. Either way a stored query string
is no longer appended on submit.
Few forms need them, so until a form has parameters a link brings up the rows. An editor adds the parameters one row at a time, a name and a value of text and merge tags, and they are stored as text: fixed text URL-encoded, tags as the placeholders the email notification understands:
vestiging={{ $vestiging }}&bron=website&form={{ $form_title }}
A query string stored with a part that is no parameter, such as a name without
=, stays a text field to edit by hand. Below the rows, the editor sees the
URL the latest submission would have sent its visitor to.
SubmissionPlaceholders::appendQuery() fills them in from the submission,
URL-encodes the values and appends the result to the resolved redirect URL,
keeping any query string or fragment that URL already carries. A placeholder
without a value leaves its parameter empty. That same class backs the email
notification, so both understand exactly the same tags.
Customizing the redirect field
By default, the URL branch is a single URL TextInput. Register a custom schema
(and a matching resolver) from a service provider's boot() to swap or extend
it, e.g. to let editors pick an internal page instead of typing a URL.
use VanOns\FilamentFormBuilder\FilamentFormBuilderPlugin;
// Replace the URL-branch field schema. Bind your field(s) to `url`, the
// outcome's key. Returns an array of components.
FilamentFormBuilderPlugin::redirectSchemaUsing(fn () => [
MyPagePicker::make('url')->required()->columnSpanFull(),
]);
// Turn the stored value (string or array) into the final redirect URL.
FilamentFormBuilderPlugin::resolveRedirectUrlUsing(function (mixed $stored, Form $form): ?string {
if (is_array($stored)) {
return $stored['url'] ?? null; // resolve your structured value
}
return is_string($stored) ? $stored : null;
});Both hooks are optional; the defaults keep the plain URL TextInput and
string passthrough. Neither runs when a form type returns its own response()
(e.g. JSON for an app), so call $this->resolveSubmitNotification($submission)
there to get the resolved values.
Modifying the redirect URL and message per submission
A form type may override modifySubmitNotification() to change the redirect
URL or the notification message based on the submission. The $redirectUrl and
$notificationMessage properties hold the values configured on the form, so you
can read, extend or replace them:
public function modifySubmitNotification(FormSubmission $submission): void
{
if (($submission->data['property_type'] ?? null) === 'rental') {
$this->redirectUrl = route('rental.thanks', ['submission' => $submission]);
}
// Or drop the redirect and show a message instead.
if (empty($this->redirectUrl)) {
$this->notificationMessage = __('Thanks :name!', ['name' => $submission->data['name']]);
}
}$redirectUrlis only pre-filled when the form uses the URL branch, but a type may set it on a Content form too — a non-empty URL always wins.$notificationMessageis flashed assubmit_notification_content; setting it also flashessubmit_notification_typeascontent, so the message renders even on a URL form without a redirect.- The form model caches its type instance, so
$this->formand both properties are available in any instance method.
Hard-coding the redirect URL or message
A form type may also drop either branch from the admin, so editors can't
configure it. Both default to true:
public function hasRedirect(): bool
{
return false;
}
public function hasNotificationMessage(): bool
{
return true;
}A third toggle hides only the query string, leaving the URL itself editable. It
defaults to the redirect_query config flag:
public function hasSubmitNotificationQuery(): bool
{
return false;
}- The type toggle only shows the allowed branches, and hides itself when only one is left — that branch is then always used.
- When a form type allows neither, the whole submit notification section is hidden and the stored values are left untouched.
- A disabled branch is not read from the form on submit, so its property starts
as
null. Set it inmodifySubmitNotification():
public function hasRedirect(): bool
{
return false;
}
public function modifySubmitNotification(FormSubmission $submission): void
{
$this->redirectUrl = route('thanks', ['submission' => $submission]);
}