function user_badges_edit_form_validate in User Badges 6.2
Same name and namespace in other branches
- 6 user_badges.admin.inc \user_badges_edit_form_validate()
- 7 user_badges.admin.inc \user_badges_edit_form_validate()
- 7.2 user_badges.admin.inc \user_badges_edit_form_validate()
- 7.3 user_badges.admin.inc \user_badges_edit_form_validate()
Validate user_badges_edit_form form submissions.
File
- ./
user_badges.admin.inc, line 290 - @brief User Badges admin functions
Code
function user_badges_edit_form_validate($form, &$form_state) {
// Either a URL or an item from the image library should be selected, but not both.
if ($form_state['values']['imageurl'] && $form_state['values']['image']) {
form_set_error('image', t('You cannot both enter an image URL and select an image from the library too. A badge can only have one image.'));
}
elseif (!$form_state['values']['imageurl'] && !$form_state['values']['image']) {
form_set_error('image', t('You need to either enter an image URL or select an image from the library. Your badge needs an image.'));
}
// The image URL must be a valid url.
if ($form_state['values']['imageurl'] && !valid_url($form_state['values']['imageurl'], TRUE)) {
form_set_error('imageurl', t('This is not a valid image URL. You need to enter a complete image URL, including the "http://" at the start.'));
}
// Weights must be numeric.
if (!is_numeric($form_state['values']['weight'])) {
form_set_error('weight', t('Your value for the weight must be a number. Negative numbers are allowed, but not decimals.'));
}
}