yii2-simplemath-captcha Yii2 extension. Captcha With A Simple Math Equation

  1. Requirements
  2. Installation
  3. Usage
  4. Resources

yii2 extension. Captcha With a Simple Math Equation

Requirements

This extension required Yii 2.0 or above.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist hreitsma/yii2-simplemath-captcha "dev-master"

or add

"hreitsma/yii2-simplemath-captcha": "dev-master"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply modify your controler, add or change methode actions():

public function actions()
{
    return [
            ...
            'captcha' => [
                'class' => 'hr\captcha\CaptchaAction',
                'operators' => ['+','-','*'],
                'maxValue' => 10,
                'fontSize' => 18,
            ],
    ];
}

In view

<?=
$form->field($model, 'verifyCode')->widget(Captcha::className(), [
    'template' => '<div class="row"><div class="col-lg-2">{image}</div><div class="col-lg-10">{input}</div></div>',
])->hint('Hint: click on the equation to refresh')
?>

If you are using prettyUrl:

'rules' => [
    'site/captcha/<refresh:\d+>' => 'site/captcha',
    'site/captcha/<v:\w+>' => 'site/captcha',
]

Resources

yii2-simplemath-captcha on github.

preview

1 0
1 follower
0 downloads
Yii Version: 2.0
License: BSD-2-Clause
Category: User Interface
Developed by: henk
Created on: Apr 11, 2016
Last updated: 8 years ago

Related Extensions