You are here

function views_ui_pre_render_flatten_data in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 8.3 views_ui/admin.inc \views_ui_pre_render_flatten_data()

Flattens the structure of an element containing the #flatten property.

If a form element has #flatten = TRUE, then all of it's children get moved to the same level as the element itself. So $form['to_be_flattened'][$key] becomes $form[$key], and $form['to_be_flattened'] gets unset.

3 string references to 'views_ui_pre_render_flatten_data'
views_handler_filter::build_group_form in handlers/views_handler_filter.inc
Build the form to let users create the group of exposed filters.
views_handler_filter::expose_form in handlers/views_handler_filter.inc
Options form subform for exposed filter options.
views_handler_sort::expose_form in handlers/views_handler_sort.inc
Form for exposed handler options.

File

includes/admin.inc, line 2008
Provides the Views' administrative interface.

Code

function views_ui_pre_render_flatten_data($form) {
  foreach (element_children($form) as $key) {
    $element = $form[$key];
    if (!empty($element['#flatten'])) {
      foreach (element_children($element) as $child_key) {
        $form[$child_key] = $form[$key][$child_key];
      }

      // All done, remove the now-empty parent.
      unset($form[$key]);
    }
  }
  return $form;
}