You are here

function quotes_blocks_settings_validate in Quotes 7

Same name and namespace in other branches
  1. 6 quotes.admin.inc \quotes_blocks_settings_validate()

Validates that the new block name is valid.

File

./quotes.admin.inc, line 361
The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.

Code

function quotes_blocks_settings_validate($form, &$form_state) {
  $name = trim($form_state['values']['name']);
  if (!$name) {
    form_set_error('name', t('You must specify a valid block name.'));
  }
  else {
    $result = db_select('quotes_blocks', 'qb')
      ->fields('qb', array(
      'name',
    ))
      ->condition('qb.name', $name)
      ->execute()
      ->fetchField();
    if ($result) {
      form_set_error('name', t('The block name %name already exists. Please choose another block name.', array(
        '%name' => $name,
      )));
    }
  }
}