You are here

public function MergeContactsAction::validateConfigurationForm in CRM Core 8

Same name and namespace in other branches
  1. 8.3 modules/crm_core_contact/src/Plugin/Action/MergeContactsAction.php \Drupal\crm_core_contact\Plugin\Action\MergeContactsAction::validateConfigurationForm()
  2. 8.2 modules/crm_core_contact/src/Plugin/Action/MergeContactsAction.php \Drupal\crm_core_contact\Plugin\Action\MergeContactsAction::validateConfigurationForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides ConfigurableActionBase::validateConfigurationForm

File

modules/crm_core_contact/src/Plugin/Action/MergeContactsAction.php, line 231

Class

MergeContactsAction
Merges 2 or more contacts.

Namespace

Drupal\crm_core_contact\Plugin\Action

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  $primary_contact = array_filter($form_state
    ->getValue('table')['contact_id']);
  if (empty($primary_contact)) {
    $form_state
      ->setError($form['table']['contact_id'], $this
      ->t('You must select primary contact in table header!'));
  }
  if (count($primary_contact) > 1) {
    $form_state
      ->setError($form['table']['contact_id'], $this
      ->t('Supplied more than one primary contact!'));
  }
}