Implementation method of adding verification code in yii2, yii2 verification code_PHP tutorial

WBOY
Release: 2016-07-12 09:01:13
Original
958 people have browsed it

The implementation method of adding verification code in yii2, yii2 verification code

The example in this article describes the implementation method of adding verification code in yii2. Share it with everyone for your reference, the details are as follows:

First, add the verification code field in the model:

public function rules(){
return ['verifyCode', 'captcha'],
}

Copy after login

Secondly, you can add the field name of the verification code in the front page in the function attributeLabels:

public function atrributeLabels(){
return ['verifyCode'=>'Verification Code', ];
}

Copy after login

Then, make the following changes in the view file:

use yii\captcha\Captcha;
<&#63;= $form->field($model, 'verifyCode')->widget(Captcha::className(), [
          'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
 ]) &#63;>

Copy after login

I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.

Articles you may be interested in:

  • Yii2 uses Bootbox plug-in to implement custom pop-up windows
  • Learn YII2 framework from scratch (4) Extension plug-in yii2-kartikgii
  • Learn the YII2 framework from scratch (3) Extend the plug-in yii2-gird
  • Learn the YII2 framework from scratch (2) Install the extension plug-in through Composer
  • Use the drop-down menu in the yii2 framework Automatic search for yii-widget-select2 instance analysis
  • Method of using Active Record mode in yii2
  • Example of usage of Activeform form component in YII2.0
  • Yii2 framework reference bootstrap Methods of date plug-in yii2-date-picker

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1089938.htmlTechArticleThe implementation method of adding verification code in yii2, yii2 verification code This article describes the implementation method of adding verification code in yii2 . Share it with everyone for your reference, the details are as follows: First, in the model...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!