yiisoft/yii — pull request #1410 by resurtm (2012-09-15 15:52:18+00:00)
Title: Fixes #1371: Captcha support for CForm

Fixes #1371.

This is just a prototype. If you like this solution, then I'll add necessary things (changelog line, comments, docblocks, etc.).

Usage example:
```php
$model=new LoginForm();

$form=new CForm(array(
'title'=>'Please provide your login credential',
'elements'=>array(
'username'=>array(
'type'=>'text',
'maxlength'=>32,
),
'password'=>array(
'type'=>'password',
'maxlength'=>32,
),
'rememberMe'=>array(
'type'=>'checkbox',
'attributes'=>array('class'=>'test-class'),
),
'verifyCode'=>array(
'type'=>'captcha',
'captchaAction'=>'captcha',
'showRefreshButton'=>true,
'clickableImage'=>true,
'buttonType'=>'button',
'imageOptions'=>array('class'=>'imageOptions-class'),
'buttonOptions'=>array('class'=>'buttonOptions-class'),
'separator'=>"
\n",
'inputOptions'=>array('class'=>'inputOptions-class'),
),
),
'buttons'=>array(
'login'=>array(
'type'=>'submit',
'label'=>'Login',
),
),
),$model);

if($form->submitted('login') && $form->validate())
$this->refresh();
else
$this->render('index', array('form'=>$form));
```

Result:
![https://dl.dropbox.com/u/916366/github/cform-captcha.png](https://dl.dropbox.com/u/916366/github/cform-captcha.png)