function views_ui_add_ajax_wrapper

After-build function that adds a wrapper to a form region (AJAX refreshes).

This function inserts a wrapper around the region of the form that needs to be refreshed by AJAX, based on information stored in the corresponding submit button form element.

1 string reference to 'views_ui_add_ajax_wrapper'
views_ui_add_ajax_trigger in includes/admin.inc
Converts a form element in the add view wizard to be AJAX-enabled.

File

includes/admin.inc, line 653

Code

function views_ui_add_ajax_wrapper($element, &$form_state) {
    // Don't add the wrapper <div> if the same one was already inserted on this
    // form.
    if (empty($element['#views_ui_ajax_data']['duplicate_wrapper'])) {
        // Find the region of the complete form that needs to be refreshed by AJAX.
        // This was earlier stored in a property on the element.
        $complete_form =& $form_state['complete form'];
        $refresh_parents = $element['#views_ui_ajax_data']['refresh_parents'];
        $refresh_element = drupal_array_get_nested_value($complete_form, $refresh_parents);
        // The HTML ID that AJAX expects was also stored in a property on the
        // element, so use that information to insert the wrapper <div> here.
        $id = $element['#views_ui_ajax_data']['wrapper'];
        $refresh_element += array(
            '#prefix' => '',
            '#suffix' => '',
        );
        $refresh_element['#prefix'] = '<div id="' . $id . '" class="views-ui-ajax-wrapper">' . $refresh_element['#prefix'];
        $refresh_element['#suffix'] .= '</div>';
        // Copy the element that needs to be refreshed back into the form, with our
        // modifications to it.
        drupal_array_set_nested_value($complete_form, $refresh_parents, $refresh_element);
    }
    return $element;
}