You are here

private function WebformCivicrmPostProcess::isContactEmpty in Webform CiviCRM Integration 8.5

Check if at least one required field was filled for a contact

Parameters

array $contact:

Return value

bool

1 call to WebformCivicrmPostProcess::isContactEmpty()
WebformCivicrmPostProcess::preSave in src/WebformCivicrmPostProcess.php
Process webform submission when it is about to be saved. Called by the following hook:

File

src/WebformCivicrmPostProcess.php, line 637
Front-end form validation and post-processing.

Class

WebformCivicrmPostProcess

Namespace

Drupal\webform_civicrm

Code

private function isContactEmpty($contact) {
  $contact_type = $contact['contact'][1]['contact_type'];
  $utils = \Drupal::service('webform_civicrm.utils');
  foreach ($utils
    ->wf_crm_required_contact_fields($contact_type) as $f) {
    if (!empty($contact[$f['table']][1][$f['name']])) {
      return FALSE;
    }
  }
  return TRUE;
}