Skip navigation
Help

uc_order_edit_form_validate

6 uc_order.admin.inc uc_order_edit_form_validate($form, &$form_state)
7 uc_order.admin.inc uc_order_edit_form_validate($form, &$form_state)

Prevents order edits from colliding.

See also

uc_order_edit_form()

uc_order_edit_form_submit()

theme_uc_order_edit_form()

File

ubercart/uc_order/uc_order.admin.inc, line 1009
Order administration menu items.

Code

function uc_order_edit_form_validate($form, &$form_state) {
  $order = uc_order_load($form_state['values']['order_id']);
  if ($form_state['values']['order_modified'] != $order->modified) {
    form_set_error('order_modified', t('This order has been modified by another user, changes cannot be saved.'));
  }

  entity_form_field_validate('uc_order', $form, $form_state);

  // Build list of changes to be applied.
  $panes = _uc_order_pane_list();
  foreach ($panes as $id => $pane) {
    if (in_array('edit', $pane['show'])) {
      $func = $pane['callback'];
      if (function_exists($func)) {
        if (($changes = $func('edit-process', $order, $form, $form_state)) != NULL) {
          foreach ($changes as $key => $value) {
            $form_state['order']->$key = $value;
          }
        }
      }
    }
  }
}