function views_ui_rearrange_form_submit in Views (for Drupal 7) 6.2
Same name and namespace in other branches
- 8.3 views_ui/admin.inc \views_ui_rearrange_form_submit()
- 6.3 includes/admin.inc \views_ui_rearrange_form_submit()
- 7.3 includes/admin.inc \views_ui_rearrange_form_submit()
Submit handler for rearranging form
File
Code
function views_ui_rearrange_form_submit($form, &$form_state) {
$types = views_object_types();
$display =& $form_state['view']->display[$form_state['display_id']];
$old_fields = $display->handler
->get_option($types[$form_state['type']]['plural']);
$new_fields = $order = array();
// Make an array with the weights
foreach ($form_state['values']['fields'] as $field => $info) {
// add each value that is a field with a weight to our list, but only if
// it has had its 'removed' checkbox checked.
if (is_array($info) && isset($info['weight']) && empty($info['removed'])) {
$order[$field] = $info['weight'];
}
}
// Sort the array
asort($order);
// Create a new list of fields in the new order.
foreach (array_keys($order) as $field) {
$new_fields[$field] = $old_fields[$field];
}
$display->handler
->set_option($types[$form_state['type']]['plural'], $new_fields);
// Store in cache
views_ui_cache_set($form_state['view']);
}