Hi all,
I’m trying to configure Captcha field in my registration form, but the image isn’t visible.
The security code is generating correctly.
There is one interesting moment, when I extend the module controller from CController everything works fine, but if to extend it with CoreController the problem appears again.
class CoreController extends CController {
public $layout = '//layouts/column1';
public $menu = array();
public $breadcrumbs = array();
public function actionError() {
if ($error = Yii::app()->errorHandler->error) {
if (Yii::app()->request->isAjaxRequest) {
echo $error['message'];
} else {
$this->layout = 'core.views.layouts.error';
$this->render('error', $error);
}
}
}
<?php
class DefaultController extends CoreController {
public function actions() {
return array(
'captcha' => array(
'class' => 'CCaptchaAction',
'backColor' => 0xFFFFFF,
),
array(
'page' => array(
'class' => 'CViewAction',
),
),
);
}
public function actionIndex() {
$this->render('index');
}
public function actionLogin() {
//....
}
public function actionLogout() {
Yii::app()->user->logout();
$this->redirect(Yii::app()->homeUrl);
}
public function actionRegistration() {
$model = new Users('registration');
//....
}
}
<?php if(CCaptcha::checkRequirements()): ?>
<div class="row">
<?php echo $form->labelEx($model, 'verifyCode'); ?>
<div>
<?php echo $form->textField($model, 'verifyCode'); ?>
<br>
<?php $this->widget('CCaptcha'); ?>
</div>
<?php echo $form->error($model, 'verifyCode'); ?>
</div>
<?php endif; ?>
array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements(), 'on' => 'registration'),