You are here

function _botcha_form_validate in BOTCHA Spam Prevention 7.2

Same name and namespace in other branches
  1. 6 botcha.botcha.inc \_botcha_form_validate()
  2. 6.2 botcha.module \_botcha_form_validate()
  3. 7 botcha.module \_botcha_form_validate()

Custom form validation - jump to __botcha_form_validate(). FIXME: Is there a standard way to put #validate handlers in a separate file?

1 string reference to '_botcha_form_validate'
BotchaRecipebookAbstract::apply in controller/botcha_recipebook.controller.inc

File

./botcha.module, line 327

Code

function _botcha_form_validate($form, &$form_state) {

  // FIXME: where does this empty value come from ? happens with comments
  unset($form_state['values']['']);

  // Get an instance of BOTCHA special form handler.
  $botcha_form = Botcha::getForm($form['form_id']['#value'], FALSE);

  // Check if it is allowed to protect.
  if ($botcha_form
    ->isEnabled()) {

    // Fetch a recipe book and handle spam protection.
    $recipebook = $botcha_form
      ->getRecipebook();
    if ($recipebook
      ->isApplicable($form, $form_state)) {
      if ($recipebook
        ->isSpam($form, $form_state)) {
        $recipebook
          ->handle('spam', $form, $form_state);
      }
      else {
        $recipebook
          ->handle('success', $form, $form_state);
      }
    }
  }
}