On this page
function _field_sort_items
_field_sort_items($field, $items)
Helper function to sort items in a field according to user drag-n-drop reordering.
Related topics
File
- modules/field/field.module, line 524
- Attach custom data fields to Drupal entities.
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;
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field!field.module/function/_field_sort_items/7.x