Hi,
there is no direct support for captcha in the new Yiistrap. I would like to share my simple solution for this.
Controller
Define CCaptchaAction as usually:
public function actions() {
return array(
// ...
'captcha' => array(
'class' => 'CCaptchaAction',
'backColor' => 0xFFFFFF,
),
// ...
);
}
Model
Use captcha validator as usually:
public function rules() {
return array(
// ...
array('verifyCode', 'captcha', 'allowEmpty' => ! CCaptcha::checkRequirements()),
// ...
);
}
View
Here comes the trick:
<?php echo $form->textFieldControlGroup($model, 'verifyCode', array(
'help' => 'Please enter the letters as they are shown in the image above.',
'controlOptions' => array('before' => $this->widget('system.web.widgets.captcha.CCaptcha', array(), true) . '<br/>'),
)); ?>