You are here

public function MergeContactsAction::submitConfigurationForm 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::submitConfigurationForm()
  2. 8.2 modules/crm_core_contact/src/Plugin/Action/MergeContactsAction.php \Drupal\crm_core_contact\Plugin\Action\MergeContactsAction::submitConfigurationForm()

Form submission 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 PluginFormInterface::submitConfigurationForm

File

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

Class

MergeContactsAction
Merges 2 or more contacts.

Namespace

Drupal\crm_core_contact\Plugin\Action

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  $data = [
    'contact_id' => array_shift(array_keys(array_filter($form_state
      ->getValue('table')['contact_id']))),
  ];
  unset($form_state
    ->getValue('table')['contact_id']);
  foreach ($form_state
    ->getValue('table') as $field_name => $selection) {
    $data[$field_name] = array_shift(array_keys(array_filter($selection)));
  }
  $this->configuration['data'] = array_filter($data);
}