You are here

function hosting_alias_site_form_validate in Hosting 6.2

Same name and namespace in other branches
  1. 7.4 alias/hosting_alias.module \hosting_alias_site_form_validate()
  2. 7.3 alias/hosting_alias.module \hosting_alias_site_form_validate()

Validation handler for site form.

Makes sure aliases are not more than HOSTING_MAX_ALIAS_LENGTH characters.

1 string reference to 'hosting_alias_site_form_validate'
hosting_alias_form_alter in alias/hosting_alias.module
Implementation of hook_form_alter().

File

alias/hosting_alias.module, line 73
Allow sites to have domain aliases that they can be accessed with.

Code

function hosting_alias_site_form_validate($form, &$form_state) {
  $aliases = $form_state['values']['aliases'];
  foreach ($aliases as $key => $alias) {
    $length = strlen(trim($alias));
    if ($length > HOSTING_MAX_ALIAS_LENGTH) {
      $long = $length - HOSTING_MAX_ALIAS_LENGTH;
      form_set_error("aliases_wrapper][aliases][{$key}", t('The alias @alias is @long character(s) too long. Please shorten.', array(
        '@alias' => $alias,
        '@long' => $long,
      )));
    }
  }
}