1 views_ui.admin.inc views_ui_add_ajax_wrapper($element, &$form_state)

After-build function that adds a wrapper to a form region (for 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.


core/modules/views_ui/views_ui.admin.inc, line 729
Admin page callbacks for the Views UI module.


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 = backdrop_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.
    backdrop_array_set_nested_value($complete_form, $refresh_parents, $refresh_element);

  return $element;