You are here

public function BotchaRecipeUsingJsAbstract::generateFormElements in BOTCHA Spam Prevention 7.3

Same name and namespace in other branches
  1. 6.2 controller/botcha_recipe.controller.inc \BotchaRecipeUsingJsAbstract::generateFormElements()
  2. 6.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeUsingJsAbstract::generateFormElements()
  3. 7.2 controller/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. @see?

Overrides BotchaRecipe::generateFormElements

3 calls to BotchaRecipeUsingJsAbstract::generateFormElements()
BotchaRecipeHoneypot2::generateFormElements in controller/recipe/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. @see?
BotchaRecipeHoneypot::isSpam in controller/recipe/botcha.recipe.controller.inc
Spam check.
BotchaRecipeObscureUrl::generateFormElements in controller/recipe/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. @see?
2 methods override BotchaRecipeUsingJsAbstract::generateFormElements()
BotchaRecipeHoneypot2::generateFormElements in controller/recipe/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. @see?
BotchaRecipeObscureUrl::generateFormElements in controller/recipe/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. @see?

File

controller/recipe/botcha.recipe.controller.inc, line 482
Controller layer of the BotchaRecipe objects.

Class

BotchaRecipeUsingJsAbstract

Code

public function generateFormElements() {
  $fields = $this
    ->getProperty($this->settings['fields'], 'getFields');
  $js = $this
    ->getProperty($this->settings['js'], '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.
      // @see?
      '#suffix' => '</div>' . '<noscript>' . t('Please enable Javascript to use this form.') . '</noscript>',
      // @todo Abstract it.

      //'#attributes' => array('class' => $fields[0]['class'], 'autocomplete' => 'off'),
      '#attributes' => array(
        'class' => array(
          $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, 'inline');
    drupal_add_js($js_value, array(
      'type' => 'inline',
      'preprocess' => FALSE,
    ));
  }
  return array_merge(parent::generateFormElements(), $form_elements);
}