You are here

function BotchaRecipeUsingJsAbstract::generateFormElements in BOTCHA Spam Prevention 6.2

Same name and namespace in other branches
  1. 6.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeUsingJsAbstract::generateFormElements()
  2. 7.2 controller/botcha_recipe.controller.inc \BotchaRecipeUsingJsAbstract::generateFormElements()
  3. 7.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeUsingJsAbstract::generateFormElements()

Used to get information about the recipe. Must be overridden with calling to parent::generateFormElements. @todo Switch from indexed array to associative.

Overrides BotchaRecipe::generateFormElements

2 calls to BotchaRecipeUsingJsAbstract::generateFormElements()
BotchaRecipeHoneypot::isSpam in controller/botcha_recipe.controller.inc
Spam check.
BotchaRecipeObscureUrl::generateFormElements in controller/botcha_recipe.controller.inc
Used to get information about the recipe. Must be overridden with calling to parent::generateFormElements. @todo Switch from indexed array to associative.
1 method overrides BotchaRecipeUsingJsAbstract::generateFormElements()
BotchaRecipeObscureUrl::generateFormElements in controller/botcha_recipe.controller.inc
Used to get information about the recipe. Must be overridden with calling to parent::generateFormElements. @todo Switch from indexed array to associative.

File

controller/botcha_recipe.controller.inc, line 431
Controller layer of the BotchaRecipe objects.

Class

BotchaRecipeUsingJsAbstract

Code

function generateFormElements() {
  $fields = $this
    ->getSetting('fields', $this
    ->getFields());
  $js = $this
    ->getSetting('js', $this
    ->getJs());
  $form_elements = array(
    $fields[0]['name'] => array(
      '#type' => 'textfield',
      '#title' => t('Enter your name'),
      // Leave the bot enough hints for it to guess it is a good name field
      '#default_value' => $fields[0]['default_value'],
      // Store part of secure_token
      '#description' => t('Your first name.'),
      // This is for human users without CSS.
      '#prefix' => '<div class="' . $fields[0]['class'] . '">' . '<span class="description"> (' . t('If you\'re a human, don\'t change the following field') . ')</span>',
      // @todo Move it to constant since it is also used in error_text.
      '#suffix' => '</div>' . '<noscript>' . t('Please enable Javascript to use this form.') . '</noscript>',
      // @todo Abstract it.

      //'#attributes' => array('class' => array($fields[0]['class']), 'autocomplete' => 'off'),
      '#attributes' => array(
        'class' => $fields[0]['class'],
        'autocomplete' => 'off',
      ),
      '#weight' => -20,
      '!valid_token' => $js['secure_token'],
    ),
  );
  $js_value = $this
    ->getProperty($this->settings['js']['value'], 'getJsValue');
  if (!empty($js_value)) {

    // @todo Abstract it.

    //drupal_add_js($js_value, array('type' => 'inline', 'preprocess' => FALSE));
    drupal_add_js($js_value, 'inline');
  }
  return array_merge(parent::generateFormElements(), $form_elements);
}