profile_field_form_validate

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

modules/profile/profile.module, строка 307

Версии
5
profile_field_form_validate($form_id, $form_values)
6
profile_field_form_validate($form, &$form_state)

Validate profile_field_form submissions.

Код

<?php
function profile_field_form_validate($form_id, $form_values) {
  // Validate the 'field name':
  if (preg_match('/[^a-zA-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 except 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.'));
  }
  if ($form_values['visibility'] == PROFILE_HIDDEN) {
    if ($form_values['required']) {
      form_set_error('required', t('A hidden field cannot be required.'));
    }
    if ($form_values['register']) {
      form_set_error('register', t('A hidden field cannot be set to visible on the user registration form.'));
    }
  }
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему