sfReCaptchaFormPlugin - 0.8.0

Easily add reCAPTCHA to a symfony form. This plugin is tested and built on top of sfFormExtraPlugin.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

sfReCaptchaFormPlugin

Very simple, test, plugin to add reCAPTCHA to a symfony form.

Usage

To add recaptcha to your form, simply call embedRecaptcha() from inside the configure() method of your form:

class myForm extends BaseForm
{
  public function configure()
  {
    $this->embedRecaptch();
  }
}

In the view, output a field called captcha as you normally would:

<?php echo $form['captcha']->render() ?>

The validation of the captcha will take place automatically.

Installation

To install this plugin from git:

git submodule add git://github.com/weaverryan/sfReCaptchaFormPlugin.git plugins/sfReCaptchaFormPlugin
git submodule init

Configuration

The only configuration needed are the reCAPTCHA public and private keys. First, obtain a public and private key via https://www.google.com/recaptcha/admin/create.

Next, in your application's app.yml file, add the following:

all:
  recaptcha:
    recaptcha_public_key:   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    recaptcha_private_key:  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Advanced Configuration

The app.yml file that comes packaged with the plugin shows all of the configuration options:

Most notably, you can automatically enable ReCaptcha on any form by specifying the form class in app.yml. If you do this, you won't need to call embedRecaptcha() from within your form:

all:
  recaptcha:
    forms:
      myProductForm:    true

The Fine Details

This plugin was taken from sympal CMF and was developed by both Jon Wage and Ryan Weaver.

A bug tracker is available for this plugin at http://redmine.sympalphp.org/projects/recaptchaplugin.

If you have questions, comments or anything else, email me at ryan [at] thatsquality.com