You are here

function ViewsSend::viewsFormValidate in Views Send 8

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

Overrides BulkForm::viewsFormValidate

File

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

Class

ViewsSend
Defines a simple send mass mail form element.

Namespace

Drupal\views_send\Plugin\views\field

Code

function viewsFormValidate(&$form, FormStateInterface $form_state) {
  if ($form_state
    ->get('step') != 'views_form_views_form') {
    return;
  }

  // Only the first initial form is handled here.
  $field_name = $this->options['id'];
  $selection = array_filter($form_state
    ->getValue($field_name));
  if (empty($selection)) {
    $form_state
      ->setErrorByName($field_name, $this
      ->t('Please select at least one item.'));
  }
}