function entityqueue_subqueue_reverse_validate in Entityqueue 7
Validation callback to reverse items in the subqueue.
1 string reference to 'entityqueue_subqueue_reverse_validate'
- entityqueue_subqueue_edit_form in includes/
entityqueue.admin.inc - Form callback; Displays the subqueue edit form.
File
- includes/
entityqueue.admin.inc, line 134 - Administrative pages for Entity Queue.
Code
function entityqueue_subqueue_reverse_validate($form, &$form_state) {
$queue = $form_state['entityqueue_queue'];
$field_name = _entityqueue_get_target_field_name($queue->target_type);
$lang = $form[$field_name]['#language'];
foreach (array(
'input',
'values',
) as $state) {
if (isset($form_state[$state][$field_name][$lang])) {
$field_values = $form_state[$state][$field_name][$lang];
foreach ($field_values as $key => $value) {
if (!is_numeric($key) || empty($value['target_id']) || $value['target_id'] == '_none') {
unset($field_values[$key]);
}
}
$field_values = array_reverse($field_values);
// Set weights according to their new order.
foreach ($field_values as $key => $value) {
if (is_numeric($key)) {
$field_values[$key]['_weight'] = $key;
}
}
$form_state[$state][$field_name][$lang] = $field_values;
}
}
}