You are here

function _quotes_blocks_validate in Quotes 5

Validates that the new block name is valid.

Parameters

$form_id: The string specifying the form ID of the form that was submitted.

$form_values: The array specifying the form values.

File

./quotes.module, line 1854

Code

function _quotes_blocks_validate($form_id, $form_values) {
  $name = trim($form_values['name']);
  if (!$name) {
    form_set_error('name', t('You must specify a valid block name.'));
  }
  else {
    if (db_result(db_query("SELECT COUNT(*) FROM {quotes_blocks} qb WHERE qb.name = '%s'", $name))) {
      form_set_error('name', t('The block name %name already exists. Please choose another block name.', array(
        '%name' => $name,
      )));
    }
  }
}