function wf_crm_enabled_fields in Webform CiviCRM Integration 7.4
Same name and namespace in other branches
- 7.5 includes/utils.inc \wf_crm_enabled_fields()
- 7.3 webform_civicrm_utils.inc \wf_crm_enabled_fields()
Get ids or values of enabled CiviCRM fields for a webform.
Parameters
stdClass $node: Node object
array|null $submission: (optional) if supplied, will match field keys with submitted values
boolean $show_all: (optional) if true, get every field even if it belongs to a contact that does not exist
Return value
array of enabled fields
14 calls to wf_crm_enabled_fields()
- webform_civicrm_update_7300 in ./
webform_civicrm.install - Note: There are differences in how contact references and relationships work in the 3.x branch. Read the upgrade instructions at http://drupal.org/node/1615380
- wf_crm_admin_component::alterForm in includes/
wf_crm_admin_component.inc - Alter back-end webform component edit forms. Called by hook_form_alter() whenever editing a webform component.
- wf_crm_admin_component::checkBillingPagination in includes/
wf_crm_admin_component.inc - Ensure billing fields are not on same page as event/member amounts
- wf_crm_admin_component::preprocessComponentsForm in includes/
wf_crm_admin_component.inc - Add CiviCRM info and theming to webform components form.
- wf_crm_admin_form::buildForm in includes/
wf_crm_admin_form.inc - Build admin form for civicrm tab of a webform
File
- includes/
utils.inc, line 417 - Webform CiviCRM module's common utility functions.
Code
function wf_crm_enabled_fields($node, $submission = NULL, $show_all = FALSE) {
$enabled = array();
if (!empty($node->webform['components']) && (!empty($node->webform_civicrm) || $show_all)) {
$fields = wf_crm_get_fields();
foreach ($node->webform['components'] as $c) {
$exp = explode('_', $c['form_key'], 5);
$customGroupFieldsetKey = "";
if (count($exp) == 5) {
list($lobo, $i, $ent, $n, $id) = $exp;
if ($lobo != 'civicrm') {
continue;
}
$explodedId = explode('_', $id);
if (wf_crm_aval($explodedId, 1) == 'fieldset' && $explodedId[0] != 'fieldset') {
$customGroupFieldsetKey = $explodedId[0];
// Automatically enable 'Create mode' field for Contact's custom group.
if ($ent === 'contact') {
$enabled[$lobo . '_' . $i . '_' . $ent . '_' . $n . '_' . $customGroupFieldsetKey . '_createmode'] = 1;
}
}
if ((isset($fields[$id]) || $id == 'fieldset_fieldset' || $id == $customGroupFieldsetKey . '_fieldset') && is_numeric($i) && is_numeric($n)) {
if (!$show_all && ($ent == 'contact' || $ent == 'participant') && empty($node->webform_civicrm['data']['contact'][$i])) {
continue;
}
if ($submission) {
$enabled[$c['form_key']] = wf_crm_aval($submission, $c['cid'], NULL, TRUE);
}
else {
$enabled[$c['form_key']] = $c['cid'];
}
}
}
}
}
return $enabled;
}