You are here

public function AddUserToChannelForm::submitForm in Node.js integration 8

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

src/Form/AddUserToChannelForm.php, line 59

Class

AddUserToChannelForm

Namespace

Drupal\nodejs\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if (nodejs_add_user_to_channel($form_state
    ->getValue('nodejs_uid'), $form_state
    ->getValue('nodejs_channel'))) {
    $this
      ->messenger()
      ->addStatus($this
      ->t("Added uid %uid to %channel.", array(
      '%uid' => $form_state
        ->getValue('nodejs_uid'),
      '%channel' => $form_state
        ->getValue('nodejs_channel'),
    )));
  }
  else {
    $this
      ->messenger()
      ->addError($this
      ->t("Failed to add uid %uid to %channel.", array(
      '%uid' => $form_state
        ->getValue('nodejs_uid'),
      '%channel' => $form_state
        ->getValue('nodejs_channel'),
    )));
  }
}