function _field_sort_items

Helper function to sort items in a field according to user drag-n-drop reordering.

Related topics

1 call to _field_sort_items()
field_default_submit in modules/field/field.default.inc

File

modules/field/field.module, line 524

Code

function _field_sort_items($field, $items) {
    if (($field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED) && isset($items[0]['_weight'])) {
        usort($items, '_field_sort_items_helper');
        foreach ($items as $delta => $item) {
            if (is_array($items[$delta])) {
                unset($items[$delta]['_weight']);
            }
        }
    }
    return $items;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.