You are here

function captcha_element_info in CAPTCHA 7

Implements of hook_element_info().

File

./captcha.module, line 153
This module enables basic CAPTCHA functionality: administrators can add a CAPTCHA to desired forms that users without the 'skip CAPTCHA' permission (typically anonymous visitors) have to solve.

Code

function captcha_element_info() {

  // Define the CAPTCHA form element with default properties.
  $captcha_element = array(
    '#input' => TRUE,
    '#process' => array(
      'captcha_element_process',
    ),
    // The type of challenge: e.g. 'default', 'none', 'captcha/Math', 'image_captcha/Image'.
    '#captcha_type' => 'default',
    // Forces captcha validation for all cases if TRUE.
    '#captcha_always' => FALSE,
    '#default_value' => '',
    // CAPTCHA in admin mode: presolve the CAPTCHA and always show it (despite previous successful responses).
    '#captcha_admin_mode' => FALSE,
    // The default CAPTCHA validation function.
    // TODO: should this be a single string or an array of strings (combined in OR fashion)?
    '#captcha_validate' => 'captcha_validate_strict_equality',
  );

  // Override the default CAPTCHA validation function for case insensitive validation.
  // TODO: shouldn't this be done somewhere else, e.g. in form_alter?
  if (CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE == variable_get('captcha_default_validation', CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE)) {
    $captcha_element['#captcha_validate'] = 'captcha_validate_case_insensitive_equality';
  }
  return array(
    'captcha' => $captcha_element,
  );
}