function webform_conditional_element_ajax in Webform 7.4
AJAX callback to render out adding a new condition.
3 string references to 'webform_conditional_element_ajax'
- _webform_conditional_action_expand in includes/
webform.conditionals.inc - Helper. Generate form elements for one action.
- _webform_conditional_add_expand in includes/
webform.conditionals.inc - Helper. Generate the add_subconditional (+) or add + button.
- _webform_conditional_remove_expand in includes/
webform.conditionals.inc - Helper. Generate the add_subconditional (+), add + or remove - button.
File
- includes/
webform.conditionals.inc, line 870 - Form elements and menu callbacks to provide conditional handling in Webform.
Code
function webform_conditional_element_ajax($form, $form_state) {
$button = $form_state['clicked_button'];
$parents = $button['#parents'];
// Trim down the parents to go back up to the level of this elements wrapper.
// The button name (add/remove).
array_pop($parents);
// The rule ID.
array_pop($parents);
// The "rules" grouping.
array_pop($parents);
$element = $form;
foreach ($parents as $key) {
if (!isset($element[$key])) {
// The entire conditional has been removed.
return '';
}
$element = $element[$key];
}
return drupal_render($element['conditional']);
}