You are here

public function CclActionsForm::submitForm in Custom Contextual Links 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

ccl_actions/src/Form/CclActionsForm.php, line 152
Contains \Drupal\ccl_actions\Form\CclActionsForm.

Class

CclActionsForm

Namespace

Drupal\ccl_actions\Form

Code

public function submitForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $form_state
    ->setValue([
    'ccl_type',
  ], 'action');
  $selected_actions = array_filter($form_state
    ->getValue([
    'actions_select',
  ]));
  $form_state
    ->setValue([
    'ccl_title',
  ], \Drupal::translation()
    ->formatPlural(count($selected_actions), 'Action %actions', ' Actions %actions', [
    '%actions' => implode(', ', array_keys($selected_actions)),
  ]));
  $form_state
    ->setValue([
    'ccl_link',
  ], '- n/a -');
  module_load_include('inc', 'ccl', 'ccl.admin');
  ccl_add_form_submit($form, $form_state);
}