Skip to content

Instantly share code, notes, and snippets.

@devster
Created March 27, 2012 10:19
Show Gist options
  • Save devster/2214618 to your computer and use it in GitHub Desktop.
Save devster/2214618 to your computer and use it in GitHub Desktop.
Basic Form robot protection sf1
<?php
class MyForm extends sfForm
{
protected $robotProtectionFieldName = "_honeypot_robot";
public function __construct($defaults = array(), $options = array(), $CSRFSecret = null)
{
parent::__construct($defaults, $options, $CSRFSecret);
$this->validatorSchema[$this->robotProtectionFieldName] = new sfValidatorRegex(array('required' => false, 'pattern' => '/^$/'));
$this->widgetSchema[$this->robotProtectionFieldName] = new sfWidgetFormInputText(array('is_hidden' => true), array('style' => 'display: none;'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment