amnah/yii-recaptcha

Yii - Recaptcha widget and validator

Maintainers

👁 amnah

Package info

github.com/amnah/yii-recaptcha

pkg:composer/amnah/yii-recaptcha

Statistics

Installs: 1 391

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

dev-master 2013-10-01 03:11 UTC

Requires

None

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT c32358b283a77d5843ed952e9ab5ceb92a8a81fe

  • amnah

recaptchayii

This package is not auto-updated.

Last update: 2026-06-15 23:56:43 UTC


README

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

Please see https://developers.google.com/recaptcha/docs/customization.

Installation

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(...)); ?>