You are here

public function BotchaRecipeHoneypot2::generateFormElements in BOTCHA Spam Prevention 7.3

Same name and namespace in other branches
  1. 6.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeHoneypot2::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 BotchaRecipeUsingJsAbstract::generateFormElements

File

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

Class

BotchaRecipeHoneypot2

Code

public function generateFormElements() {
  $fields = $this
    ->getProperty($this->settings['fields'], 'getFields');
  $js = $this
    ->getProperty($this->settings['js'], 'getJs');
  $chops_positions = array_keys($js['chops']);
  $css_tok2 = substr($js['secure_token'], $chops_positions[0] + $chops_positions[1]);
  $form_elements = parent::generateFormElements();

  // Set 'style' attribute for our field. It will be used by JavaScript to
  // calculate and fill in correct value to this hidden field.
  // 'a' before css token is because font name must start with a letter.
  $form_elements[$fields[0]['name']]['#attributes']['style'] = "font-family: \"a{$css_tok2}\"";
  return $form_elements;
}