function webform_civicrm_ajax_form_item in Webform CiviCRM Integration 6.2
Same name and namespace in other branches
- 7.2 webform_civicrm_d7_functions.inc \webform_civicrm_ajax_form_item()
Add an ajax container to a form, and set an existing form element to control it
Parameters
$form: the entire form:
$pathstr: a : separated string of nested array keys leading to the relevant form snippet:
$control_element: str. Array key of the existing element to add ajax behavior to:
$container: str. Array key of the container to be created:
1 call to webform_civicrm_ajax_form_item()
- webform_civicrm_configure_form_builder in ./
webform_civicrm_admin.inc - Form to configure CiviCRM options for a Webform Called indirectly from hook_menu() for D7-D6 compatibility
File
- ./
webform_civicrm_d6_functions.inc, line 94 - Keep all functions specific to a version of Drupal here, to allow the rest of the code to be version-independent.
Code
function webform_civicrm_ajax_form_item(&$form, $pathstr, $control_element, $container) {
eval('$snippet = &$form[\'' . str_replace(':', "']['", $pathstr) . "'];");
$pathstr = str_replace(':', '.', $pathstr) . '.' . $container;
$id = 'civicrm-ajax-' . str_replace(array(
'.',
'_',
), '-', $pathstr);
$snippet[$control_element]['#ahah'] = array(
'path' => 'webform-civicrm/js/civicrm_ahah.' . $pathstr,
'wrapper' => $id,
'effect' => 'fade',
);
$snippet[$container] = array(
'#prefix' => '<div class="civicrm-ajax-wrapper" id="' . $id . '">',
'#value' => ' ',
'#suffix' => '</div>',
);
}