/** * Initializes the honey pot. Loads CSS, and adds the field * * @param ContactForm * @return HoneyPotSpamProtector */ public function initialize(ContactForm $proxy) { Requirements::customCSS("\n\t\t\t#{$this->name} {position:absolute;left:-9999em;}\n\t\t"); $proxy->addField(TextField::create($this->name, null)->setAttribute('tabindex', '-1')); $proxy->addOmittedField($this->name); return $this; }
/** * Sets up the spam question. Chooses a question at random and adds it to the form * * @param ContactForm */ public function initialize(ContactForm $proxy) { if (sizeof($this->questions)) { $rand = rand(0, sizeof($this->questions) - 1); $q = $this->questions[$rand]; $name = "SimpleQuestion_{$rand}"; $proxy->addField(LabelField::create("SimpleSpamQuestion_label_{$rand}", $this->heading))->addField(TextField::create($name, $q['question'])); $proxy->addOmittedField($name); } }