interface FormSubmitterInterface (View source)

Provides an interface for processing form submissions.

Methods

null|Response
doSubmitForm(array $form, FormStateInterface $form_state)

Handles the submitted form, executing callbacks and processing responses.

executeSubmitHandlers($form, FormStateInterface $form_state)

Executes custom submission handlers for a given form.

RedirectResponse|null
redirectForm(FormStateInterface $form_state)

Redirects the user to a URL after a form has been processed.

Details

null|Response doSubmitForm(array $form, FormStateInterface $form_state)

Handles the submitted form, executing callbacks and processing responses.

Parameters

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.

Return Value

null|Response

If a response was set by a submit handler, or if the form needs to redirect, a Response object will be returned.

executeSubmitHandlers($form, FormStateInterface $form_state)

Executes custom submission handlers for a given form.

Button-specific handlers are checked first. If none exist, the function falls back to form-level handlers.

Parameters

$form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form. If the user submitted the form by clicking a button with custom handler functions defined, those handlers will be stored here.

RedirectResponse|null redirectForm(FormStateInterface $form_state)

Redirects the user to a URL after a form has been processed.

After a form is submitted and processed, normally the user should be redirected to a new destination page. This function figures out what that destination should be, based on the $form_state and the 'destination' query string in the request URL, and redirects the user there.

The result of \Drupal\Core\Form|FormStateInterface::getRedirect() determines where to redirect the user. See the possible return values listed there. If the result is FALSE, then the user will not be redirected.

Here is an example of how to set up a form to redirect to the path 'user':

Parameters

FormStateInterface $form_state

The current state of the form.

Return Value

RedirectResponse|null

See also

FormBuilderInterface::processForm
FormBuilderInterface::buildForm