function user_badges_products_list_form_validate in User Badges 6.2
Same name and namespace in other branches
- 6 user_badges_products.module \user_badges_products_list_form_validate()
Validate user_badges_products_list_form form submissions.
All weights should be numeric
File
- ./
user_badges_products.module, line 98 - @brief User Badges Product module file
Code
function user_badges_products_list_form_validate($form, &$form_state) {
if (isset($form['newbadge']) && is_array($form['newbadge'])) {
foreach (element_children($form['newbadge']) as $nid) {
if (!empty($form_state['values'][$nid])) {
//The field isn't empty, so we should validate it
$validation = user_badges_badge_autocomplete_validation($form_state['values'][$nid]);
//Is it correctly formatted?
if ($validation[1] == 'string') {
form_set_error($nid, t('"@value" is not a valid badge name. Try using the autocomplete function (requires javascript).', array(
'@value' => $form_state['values'][$nid],
)));
}
elseif ($validation[1] == 'nobid') {
form_set_error($nid, t('@value is not a valid badge ID. Try using the autocomplete function (requires javascript).', array(
'@value' => $validation[0],
)));
}
}
}
}
}