2017 © Pedro Peláez
 

library yii-recaptcha

Yii - Recaptcha widget and validator

image

amnah/yii-recaptcha

Yii - Recaptcha widget and validator

  • Tuesday, October 1, 2013
  • by amnah
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,309 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

YiiRecaptcha

Yii Recaptcha extension. This simple extension was built to give developers full control over their recaptcha styling via custom theming., (*1)

Please see https://developers.google.com/recaptcha/docs/customization., (*2)

Installation

  • Install via composer - https://packagist.org/packages/amnah/yii-recaptcha
  • OR extract files into vendor dir - protected/vendor/amnah/yii-recaptcha

Usage

  • Ensure that you have a model with an appropriate "recaptcha" attribute
  • Add path alias (modify path as needed)
Yii::setPathOfAlias('YiiRecaptcha',Yii::getPathOfAlias("application.vendor.amnah.yii-recaptcha"));
  • Call widget in view file (take note of the style attribute, as that determines the function it calls)
<?php $this->widget('YiiRecaptcha\Recaptcha', array(
    'model' => $model,
    'attribute' => 'recaptcha',
    'publicKey' => '<recaptcha public key>',
    'style' => 'custom',
)); ?>
/**
 * The styling of the recaptcha widget, which will decide which function to use
 * For example,
 * $style = "default"   =>     $this->runDefault();
 * $style = "custom"    =>     $this->runCustom();
 * @var string
 */
  • Add validator to model rules()
public function rules() {
    return array(
        ...
        array('recaptcha', 'required'),
        array('recaptcha', 'YiiRecaptcha\RecaptchaValidator', 'privateKey' => '<recaptcha private key>'),
        ...
    );
}

Extending

  • Create a new file that extends the YiiRecaptcha\Recaptcha or YiiRecaptcha\RecaptchaValidator class
  • Reference the new file instead of the original
<?php $this->widget('application.extensions.MyRecaptcha', array(...)); ?>

The Versions

01/10 2013

dev-master

9999999-dev https://github.com/amnah/yii-recaptcha

Yii - Recaptcha widget and validator

  Sources   Download

MIT

by Avatar amnah

yii recaptcha