Commit a1ce6bac authored by webchick's avatar webchick

#819816 by aaronbauman, yched, Damien Tournoud, tsi: Fixed Reordering...

#819816 by aaronbauman, yched, Damien Tournoud, tsi: Fixed Reordering multivalue file and image field uploads is broken.
parent 086f2ea0
......@@ -65,12 +65,10 @@ function field_default_validate($entity_type, $entity, $field, $instance, $langc
}
function field_default_submit($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) {
// Reorder items to account for drag-n-drop reordering.
if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
$items = _field_sort_items($field, $items);
}
// Filter out empty values.
$items = _field_filter_items($field, $items);
// Reorder items to account for drag-n-drop reordering.
$items = _field_sort_items($field, $items);
}
/**
......
......@@ -322,24 +322,18 @@ function _field_sort_items($field, $items) {
* (copied form element_sort(), which acts on #weight keys)
*/
function _field_sort_items_helper($a, $b) {
$a_weight = (is_array($a) && isset($a['_weight'])) ? $a['_weight'] : 0;
$b_weight = (is_array($b) && isset($b['_weight'])) ? $b['_weight'] : 0;
if ($a_weight == $b_weight) {
return 0;
}
return ($a_weight < $b_weight) ? -1 : 1;
$a_weight = (is_array($a) ? $a['_weight'] : 0);
$b_weight = (is_array($b) ? $b['_weight'] : 0);
return $a_weight - $b_weight;
}
/**
* Same as above, using ['_weight']['#value']
*/
function _field_sort_items_value_helper($a, $b) {
$a_weight = (is_array($a) && isset($a['_weight']['#value'])) ? $a['_weight']['#value'] : 0;
$b_weight = (is_array($b) && isset($b['_weight']['#value'])) ? $b['_weight']['#value'] : 0;
if ($a_weight == $b_weight) {
return 0;
}
return ($a_weight < $b_weight) ? -1 : 1;
$a_weight = (is_array($a) && isset($a['_weight']['#value']) ? $a['_weight']['#value'] : 0);
$b_weight = (is_array($b) && isset($b['_weight']['#value']) ? $b['_weight']['#value'] : 0);
return $a_weight - $b_weight;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment