Model中
//验证属性
public function rules(){
return [
[['telnumber','verifyCode','password','name'],'required'],
['telnumber','match','pattern'=>'/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/','message'=>'手机号码格式错误'],
['password','string','min'=>6,'max'=>18],
['name','string','min'=>1,'max'=>6],
['verifyCode', 'captcha','captchaAction'=>'/member/captcha'],
];
}
View中
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(),
['captchaAction'=>'/member/captcha','template' => '{input}{image}','imageOptions'=>['title'=>'换一个','alt'=>'换一个'],'options'=>['placeholder'=>'图形验证码','class'=>'verifyCode']])->label(false);?>
问题原因:只在view中设置了captchaAction属性,而Model中未设置 所以提示验证码错误。