PHP code example of bitdevelopment / yii2-validators

1. Go to this page and download the library: Download bitdevelopment/yii2-validators library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bitdevelopment / yii2-validators example snippets


use bitdevelopment\yii2validators\WordValidator;

class Post extends \yii\base\Model {

  public function rules() {
    return [
            [['myField'],WordValidator::className(),'min'=>200,'max'=>500]
    ];
  }
  ...

$form->field($model, 'comment',['validateOnType' => true])->textarea([
                    'rows'=> 15
            ]);

return [
       /*
	* Your params...
	*/
 	'reCaptcha' => [
        	'siteKey' => 'site_key',
        	'secret' => 'secret_key',
    	],
];
 
use bitdevelopment\yii2validators\ReCaptchaValidator;

class Post extends \yii\base\Model {

  public $reCaptcha;

  public function rules() {
    return [
            [['reCaptcha'], ReCaptchaValidator::className()],
	    [['reCaptcha'], '
 
echo $form->field($comments, 'reCaptcha')->widget(
            	bitdevelopment\yii2validators\ReCaptcha::className(),
        )->label(false) 

  //In your rules
  [['reCaptcha'], ReCaptchaValidator::className(),'secret'=>'secret_key'],
  ...

  //In your view
  echo $form->field($comments, 'reCaptcha')->widget(
            	bitdevelopment\yii2validators\ReCaptcha::className(),
		['siteKey','site_key']
        )->label(false) 

$ php composer.phar