капча не работает на yii - PullRequest
       8

капча не работает на yii

0 голосов
/ 04 января 2012

Модель пользователя:

public function rules()
{
    return array(
        ...
        array('verifyCode', 'captcha', 'on'=>'register'),
        ...
    );
}

UserController

public function actionRegister()
{
    $model=new User;
    if(isset($_POST['User']))
    {
        $model->attributes=$_POST['User'];
        if($model->save()){
             $this->redirect(array('login'));
        }
    }
    ...
    $this->render('register');
}

Просмотр - register.php

<?php $this->widget('CCaptcha'); ?>
            <div class="captcha"><?php echo CHtml::activeTextField( $model,'verifyCode', array('class'=>'captcha')); ?></div>
    <?php echo $form->error($model,'verifyCode'); ?>

Это делает капчу в порядке, но проверка не происходит. В чем может быть проблема?

1 Ответ

3 голосов
/ 05 января 2012

я думаю, что ваша проблема с on => регистрация попробовать 'на' => 'вставить' и читать

http://yiiframework.com/forum/index.php?/topic/25817-rules-models/

и

http://php -viousts.cubedwater.com / 2009 / validation-сценарии /

и

http://www.yiiframework.com/forum/index.php?/topic/13572-how-to-define-scenarios/

...