function commerce_invoice_form_validate in Commerce Invoice 7.2
Validation callback for the invoice form.
File
- ./
commerce_invoice.admin.inc, line 231 - Administrative form and page callbacks for the Commerce Invoice module.
Code
function commerce_invoice_form_validate(&$form, &$form_state) {
$invoice = $form_state['commerce_invoice'];
if (!empty($form_state['values']['owner'])) {
// Given username exists.
if ($account = user_load_by_name($form_state['values']['owner'])) {
$form_state['values']['uid'] = $account->uid;
}
else {
form_set_error('owner', t('The username %name does not exist.', array(
'%name' => $form_state['values']['owner'],
)));
}
}
elseif (!empty($invoice) && !empty($invoice->order_id)) {
$uid = $invoice
->wrapper()->order->owner->uid
->value();
$form_state['values']['uid'] = $uid;
}
else {
$form_state['values']['uid'] = 0;
}
}