function CivicrmContact::wf_crm_contact_fields in Webform CiviCRM Integration 8.5
Find exposed field groups for a contact
Parameters
$webform:
$con: Contact #
Return value
array
1 call to CivicrmContact::wf_crm_contact_fields()
- CivicrmContact::form in src/
Plugin/ WebformElement/ CivicrmContact.php
File
- src/
Plugin/ WebformElement/ CivicrmContact.php, line 447
Class
- CivicrmContact
- Provides a 'textfield' element.
Namespace
Drupal\webform_civicrm\Plugin\WebformElementCode
function wf_crm_contact_fields($webform, $con) {
$ret = [];
$utils = \Drupal::service('webform_civicrm.utils');
$sets = $utils
->wf_crm_get_fields('sets');
$sets['name'] = [
'label' => t('Name'),
];
$elements = $webform
->getElementsDecodedAndFlattened();
foreach ($elements as $f) {
if ($pieces = $utils
->wf_crm_explode_key($f['#form_key'])) {
list(, $c, $ent, , $table, $field) = $pieces;
if ($ent == 'contact' && $c == $con && isset($sets[$table])) {
// Separate name from other contact fields
if ($table == 'contact' && strpos($field, 'name')) {
$table = 'name';
}
if ($field != 'existing') {
$ret[$table] = $sets[$table]['label'];
}
}
}
}
return $ret;
}