/** * Renders the {@link Form} object that is managed by the ContactForm. * Includes dependencies and sets up the spam * * @return Form */ public function render() { if (ContactFormSpamProtector::ip_is_locked() && Director::isLive()) { return Controller::curr()->httpError(400); } foreach ($this->spamProtection as $spam) { $spam->initialize($this); } if (!empty($this->validation)) { if (!self::$jquery_included) { Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js"); } Requirements::javascript("contact_form/javascript/validation.js"); Requirements::customScript($this->getValidationJS()); } if ($data = Session::get("FormData.{$this->form->FormName()}")) { $this->form->loadDataFrom($data); } if (Director::is_ajax()) { return $this->form; } else { return $this->form->renderWith(array("ContactForm")); } }
/** * Sets the number of tolerable spam failures before the form stops being rendered * * @param int */ public static function set_spam_failure_limit($num) { self::$spam_failure_limit = $num; }
public function add(ContactFormSpamProtector $spam) { $spam->setContainer($this); $this->components->push($spam); return $this; }