Php 如何在yii wform中添加验证码
我正在对表单使用“wForm”扩展。我想在表格中添加“验证码”。 我试过用“myCaptcha”组件来表示“cForm”。 但是我得到了以下错误 “WForm”及其行为没有名为“MyCaptcha”的方法或闭包 如何在wForm中使用“cform验证码”?下载扩展名 1) 将CaptchaExtended.zip文件解压缩到../protected/extensions/CaptchaExtended/ 2) 注册CaptchaExtendedAction和CaptchaExtendedValidator的类路径,例如在components/controller.php中:Php 如何在yii wform中添加验证码,php,yii,captcha,Php,Yii,Captcha,我正在对表单使用“wForm”扩展。我想在表格中添加“验证码”。 我试过用“myCaptcha”组件来表示“cForm”。 但是我得到了以下错误 “WForm”及其行为没有名为“MyCaptcha”的方法或闭包 如何在wForm中使用“cform验证码”?下载扩展名 1) 将CaptchaExtended.zip文件解压缩到../protected/extensions/CaptchaExtended/ 2) 注册CaptchaExtendedAction和CaptchaExtendedVali
public function init(){
// register class paths for extension captcha extended
Yii::$classMap = array_merge( Yii::$classMap, array(
'CaptchaExtendedAction' => Yii::getPathOfAlias('ext.captchaExtended').DIRECTORY_SEPARATOR.'CaptchaExtendedAction.php',
'CaptchaExtendedValidator' => Yii::getPathOfAlias('ext.captchaExtended').DIRECTORY_SEPARATOR.'CaptchaExtendedValidator.php'
));
}
3) 在控制器中定义操作,例如SiteController:
public function actions(){
return array(
'captcha'=>array(
'class'=>'CaptchaExtendedAction',
// if needed, modify settings
'mode'=>CaptchaExtendedAction::MODE_MATH,
),
);
}
4) 在模型::规则()中定义客户端验证:
5) 在视图文件中添加以下内容(在表单中)
public function rules(){
return array(
array('verifyCode', 'CaptchaExtendedValidator', 'allowEmpty'=>!CCaptcha::checkRequirements()),
);
}
$this->widget('CCaptcha'); //for captch image
echo CHtml::activeTextField($model,'verifyCode'); //text field to enter captcha text