You are here

function twitter_block_add_block_form_validate in Twitter Block 7.2

Same name and namespace in other branches
  1. 7 twitter_block.admin.inc \twitter_block_add_block_form_validate()

Form validation handler for twitter_block_add_block_form().

See also

twitter_block_add_block_form()

twitter_block_add_block_form_submit()

1 string reference to 'twitter_block_add_block_form_validate'
twitter_block_add_block_form in ./twitter_block.admin.inc
Form constructor for the add block form.

File

./twitter_block.admin.inc, line 59
Admin page callbacks for the Twitter Block module.

Code

function twitter_block_add_block_form_validate($form, &$form_state) {
  $unique_description = (bool) db_query_range('SELECT 1 FROM {twitter_block} WHERE info = :info', 0, 1, array(
    ':info' => $form_state['values']['info'],
  ))
    ->fetchField();
  if (empty($form_state['values']['info']) || $unique_description) {
    form_set_error('info', t('Ensure that each block description is unique.'));
  }
  $unique_widget_id = (bool) db_query_range('SELECT 1 FROM {twitter_block} WHERE widget_id = :widget_id', 0, 1, array(
    ':widget_id' => $form_state['values']['widget_id'],
  ))
    ->fetchField();
  if (empty($form_state['values']['widget_id']) || $unique_widget_id) {
    form_set_error('widget_id', t('Ensure that each block widget ID is unique.'));
  }
}