You are here

function ViewsSend::viewsForm in Views Send 8

Overrides \Drupal\system\Plugin\views\field\BulkForm::viewsForm().

Overrides BulkForm::viewsForm

File

src/Plugin/views/field/ViewsSend.php, line 51

Class

ViewsSend
Defines a simple send mass mail form element.

Namespace

Drupal\views_send\Plugin\views\field

Code

function viewsForm(&$form, FormStateInterface $form_state) {
  parent::viewsForm($form, $form_state);

  // The view is empty, abort.
  if (empty($this->view->result)) {
    return;
  }

  // Add the custom CSS for all steps of the form.
  $form['#attached']['library'][] = 'views_send/views_send.form';

  // Remove standard header which is used to select action
  unset($form['header']);
  $step = $form_state
    ->get('step');
  if ($step == 'views_form_views_form') {
    $form['actions']['submit']['#value'] = $this
      ->t('Next', [], [
      'context' => 'views_send: Go to configure mail',
    ]);
    $form['#prefix'] = '<div class="views-send-selection-form">';
    $form['#suffix'] = '</div>';
  }
  else {

    // Hide the normal output from the view
    unset($form['output']);
    $step($form, $form_state, $this->view);
  }
}