Git Product home page Git Product logo

yii2-captcha's Introduction

dynamikaweb/yii2-captcha

php version pkg version license quality build

Features

  • Custom alignment
  • Centered by default
  • Not jQuery dependent
  • Not printable by default
  • Development keys by default
  • Better responsive Improvements
  • Support for google reCaptcha and also hCaptcha
  • Support for multiple validators, widgets and keys at the same time

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require dynamikaweb/yii2-captcha "*"

or add

"dynamikaweb/yii2-captcha": "*"

to the require section of your composer.json file.

Usage

Widget using input name

  • View file
<?php 

use dynamikaweb\captcha\Captcha;
?>

<?=Captcha::widget([
  'siteKey' => 'XXX',
  'name' => 'captcha',
  'pos' => Captcha::POS_LEFT // or Captcha::POS_CENTER or Captcha::POS_RIGHT (optional)
  'size' => Captcha::SIZE_COMPACT // or Captcha::SIZE_NORMAL (optional)
  'type' => Captcha::TYPE_RECAPTCHA // or Captcha::TYPE_HCAPTCHA 
])?>

Widget using model (site key in model file)

  • Model file
<?php 

namespace app\models;

use dynamikaweb\captcha\CaptchaValidator;

class SomeModel extends yii\base\Model
{
  public $captcha;

  public function rules()
  {
    return [
      [['captcha'], CaptchaValidator::classname(),
        'type' => CaptchaValidator::TYPE_RECAPTCHA, // or CaptchaValidator::TYPE_HCAPTCHA
        'siteKey' => 'XXX', // (optional)
        'secret' => 'XXX'
      ]
    ];
  }
}
  • View file
<?php 

use dynamikaweb\captcha\Captcha;
?>

<?=$form->attribute($model, 'captcha')->widget('dynamikaweb\captcha\Captcha')?>

Widget using model (site key in view file)

  • Model file
<?php 

namespace app\models;

use dynamikaweb\captcha\CaptchaValidator;

class SomeModel extends yii\base\Model
{
  public $captcha;

  public function rules()
  {
    return [
      [['captcha'], CaptchaValidator::classname(),
        'type' => CaptchaValidator::TYPE_RECAPTCHA, // or CaptchaValidator::TYPE_HCAPTCHA
        'secret' => 'XXX'
      ]
    ];
  }
}
  • View file
<?php 

use dynamikaweb\captcha\Captcha;
?>

<?=$form->attribute($model, 'captcha')->widget('dynamikaweb\captcha\Captcha', [
  'siteKey' => 'XXX',
  'size' => Captcha::SIZE_COMPACT // or Captcha::SIZE_NORMAL (optional)
  'pos' => Captcha::POS_LEFT // or Captcha::POS_CENTER or Captcha::POS_RIGHT (optional)
])?>

dynamika soluções web This project is under BSD-3-Clause license.

yii2-captcha's People

Contributors

lightinen avatar rodrigodornelles avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.