You are here

protected function WebformCivicrmBase::getExposedOptions in Webform CiviCRM Integration 8.5

For a given field, find the options that are exposed to the webform.

Parameters

$field_key: Field key

array $exclude: Options to ignore

Return value

array

10 calls to WebformCivicrmBase::getExposedOptions()
WebformCivicrmBase::loadContact in src/WebformCivicrmBase.php
Fetch all relevant data for a given contact Used to load contacts for pre-filling a webform, and also to fill in a contact via ajax
WebformCivicrmPostProcess::fillDataFromSubmission in src/WebformCivicrmPostProcess.php
Fill data array with submitted form values
WebformCivicrmPostProcess::handleEntityTags in src/WebformCivicrmPostProcess.php
Handle adding/updating tags for entities (cases, activity)
WebformCivicrmPostProcess::processParticipants in src/WebformCivicrmPostProcess.php
Process event participation for a contact
WebformCivicrmPostProcess::saveGroupsAndTags in src/WebformCivicrmPostProcess.php
Save groups and tags for a contact

... See full list

File

src/WebformCivicrmBase.php, line 554
Front-end form handler base class.

Class

WebformCivicrmBase
Class WebformCivicrmBase

Namespace

Drupal\webform_civicrm

Code

protected function getExposedOptions($field_key, $exclude = []) {
  $field = $this
    ->getComponent($field_key);
  $utils = \Drupal::service('webform_civicrm.utils');
  if ($field && $field['#type'] == 'hidden') {

    // Fetch live options
    $exposed = $utils
      ->wf_crm_field_options($field, 'civicrm_live_options', $this->data);
    foreach ($exclude as $i) {
      unset($exposed[$i]);
    }
    return $exposed;
  }
  $supportedTypes = [
    'civicrm_options',
    'checkboxes',
    'radios',
    'select',
  ];
  if (isset($field['#options']) && in_array($field['#type'], $supportedTypes)) {
    return array_diff_key($field['#options'], array_flip($exclude));
  }
  return [];
}