function commerce_customer_customer_profile_form_validate in Commerce Core 7
Validation callback for commerce_customer_profile_form().
1 string reference to 'commerce_customer_customer_profile_form_validate'
- commerce_customer_customer_profile_form in modules/
customer/ includes/ commerce_customer_profile.forms.inc - Form callback: create or edit a customer profile.
File
- modules/
customer/ includes/ commerce_customer_profile.forms.inc, line 125 - Forms for creating / editing and deleting customer profiles.
Code
function commerce_customer_customer_profile_form_validate($form, &$form_state) {
$profile = $form_state['customer_profile'];
// Validate the "owned by" field.
if (!empty($form_state['values']['name']) && !($account = user_load_by_name($form_state['values']['name']))) {
// The use of empty() is mandatory in the context of usernames as the empty
// string denotes an anonymous user.
form_set_error('name', t('The username %name does not exist.', array(
'%name' => $form_state['values']['name'],
)));
}
// Notify field widgets to validate their data.
field_attach_form_validate('commerce_customer_profile', $profile, $form, $form_state);
}