You are here

protected function StatusForm::clearFormInput in Heartbeat 8

Clears form input.

Parameters

array $form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

File

modules/statusmessage/src/Form/StatusForm.php, line 310

Class

StatusForm
Form controller for Status edit forms.

Namespace

Drupal\statusmessage\Form

Code

protected function clearFormInput(FormStateInterface $form_state) {

  // Replace the form entity with an empty instance.
  // Clear user input.
  $input = $form_state
    ->getUserInput();

  // We should not clear the system items from the user input.
  $clean_keys = $form_state
    ->getCleanValueKeys();
  $clean_keys[] = 'ajax_page_state';
  foreach ($input as $key => $item) {
    if (!in_array($key, $clean_keys) && substr($key, 0, 1) !== '_') {
      unset($input[$key]);
    }
  }
  $form_state
    ->setUserInput($input);

  // Rebuild the form state values.
  $form_state
    ->setRebuild();
  $form_state
    ->setStorage([]);
}