function profile_field_form_validate in Drupal 4
Same name and namespace in other branches
- 5 modules/profile/profile.module \profile_field_form_validate()
- 6 modules/profile/profile.admin.inc \profile_field_form_validate()
- 7 modules/profile/profile.admin.inc \profile_field_form_validate()
Validate profile_field_form submissions.
File
- modules/
profile.module, line 284 - Support for configurable user profiles.
Code
function profile_field_form_validate($form_id, $form_values) {
// Validate the 'field name':
if (eregi('[^a-z0-9_-]', $form_values['name'])) {
form_set_error('name', t('The specified form name contains one or more illegal characters. Spaces or any other special characters expect dash (-) and underscore (_) are not allowed.'));
}
if (in_array($form_values['name'], user_fields())) {
form_set_error('name', t('The specified form name is reserved for use by Drupal.'));
}
// Validate the category:
if (!$form_values['category']) {
form_set_error('category', t('You must enter a category.'));
}
if ($form_values['category'] == 'account') {
form_set_error('category', t('The specified category name is reserved for use by Drupal.'));
}
$args1 = array(
$form_values['title'],
$form_values['category'],
);
$args2 = array(
$form_values['name'],
);
$query_suffix = '';
if (isset($form_values['fid'])) {
$args1[] = $args2[] = $form_values['fid'];
$query_suffix = ' AND fid != %d';
}
if (db_result(db_query("SELECT fid FROM {profile_fields} WHERE title = '%s' AND category = '%s'" . $query_suffix, $args1))) {
form_set_error('title', t('The specified title is already in use.'));
}
if (db_result(db_query("SELECT fid FROM {profile_fields} WHERE name = '%s'" . $query_suffix, $args2))) {
form_set_error('name', t('The specified name is already in use.'));
}
}