public function CreateGdprRequestOnBehalfOfUserForm::submitForm in General Data Protection Regulation 8
Same name and namespace in other branches
- 8.2 modules/gdpr_tasks/src/Form/CreateGdprRequestOnBehalfOfUserForm.php \Drupal\gdpr_tasks\Form\CreateGdprRequestOnBehalfOfUserForm::submitForm()
- 3.0.x modules/gdpr_tasks/src/Form/CreateGdprRequestOnBehalfOfUserForm.php \Drupal\gdpr_tasks\Form\CreateGdprRequestOnBehalfOfUserForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- modules/
gdpr_tasks/ src/ Form/ CreateGdprRequestOnBehalfOfUserForm.php, line 73
Class
- CreateGdprRequestOnBehalfOfUserForm
- Form for user task requests.
Namespace
Drupal\gdpr_tasks\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$user = $this
->getRouteMatch()
->getParameter('user');
$request_type = $this
->getRouteMatch()
->getParameter('gdpr_task_type');
$notes = $form_state
->getValue('notes');
$task = Task::create([
'type' => $request_type,
'user_id' => $user
->id(),
'notes' => $notes,
]);
$task
->save();
if ($request_type === 'gdpr_sar') {
$this->queue
->createQueue();
$this->queue
->createItem($task
->id());
}
$this
->messenger()
->addStatus('The request has been logged');
$form_state
->setRedirect('view.gdpr_tasks_my_data_requests.page_1', [
'user' => $user
->id(),
]);
}