function webform_civicrm_civicrm_buildForm in Webform CiviCRM Integration 7.5
Same name and namespace in other branches
- 8.5 webform_civicrm.module \webform_civicrm_civicrm_buildForm()
- 7.4 webform_civicrm.module \webform_civicrm_civicrm_buildForm()
Implements hook_civicrm_buildForm().
Parameters
string $formName:
CRM_Core_Form $form:
File
- ./
webform_civicrm.module, line 491 - Webform CiviCRM Integration Module: Links webform submissions to contacts in a CiviCRM database. @author Coleman Watts
Code
function webform_civicrm_civicrm_buildForm($formName, $form) {
// Warn user when deleting custom fields used by webforms
if ($formName == 'CRM_Custom_Form_DeleteField') {
$nodes = [];
$fid = $form
->getVar('_id');
if ($fid) {
$webforms = db_query("SELECT nid FROM {webform_component} WHERE form_key LIKE 'civicrm_%_custom_{$fid}' GROUP BY nid");
foreach ($webforms as $webform) {
$node = node_load($webform->nid);
$nodes[] = l($node->title, 'node/' . $webform->nid);
}
}
if ($nodes) {
$list = '<ul><li>' . implode('</li><li>', $nodes) . '</li></ul>';
CRM_Core_Region::instance('page-body')
->add([
'markup' => '<strong>' . t('This field is used in the following webforms:') . '</strong>' . $list,
]);
}
}
}