Captcha in my form dont show the image!?!?

I’d copied this code from “news.php” page auto-generate from yii when I’ve create my webapp.

Now I’ve copied this:


  <?php if (CCaptcha::checkRequirements()): ?>

    <div class="row">

      <?php echo $form->labelEx($model, 'verifyCode'); ?>

      <div>

        <?php $this->widget('CCaptcha'); ?>

        <?php echo $form->textField($model, 'verifyCode'); ?>

      </div>

      <div class="hint">Please enter the letters as they are shown in the image above.

        <br/>Letters are not case-sensitive.</div>

    </div>

  <?php endif; ?>

But dont work: I dont see image.

Ok, the most simple question: Does "$this" controller got "captcha" action?

Thank you for good question!

This is from /protected/controllers/SiteController.php




  public function actions() {

    return array(

        // captcha action renders the CAPTCHA image displayed on the contact page

        'captcha' => array(

            'class' => 'CCaptchaAction',

            'backColor' => 0xFFFFFF,

        ),

        // page action renders "static" pages stored under 'protected/views/site/pages'

        // They can be accessed via: index.php?r=site/page&view=FileName

        'page' => array(

            'class' => 'CViewAction',

        ),

    );

  }

In SiteController there is this actions method. (This code is generated by yii).

Now I add this in my controller




  public function actions() {

    return array(

        // captcha action renders the CAPTCHA image displayed on the contact page

        'captcha' => array(

            'class' => 'CCaptchaAction',

            'backColor' => 0xFFFFFF,

        ),

    );

  }

BUT this is not enough

Image is the resutl of a link like


http://localhost/****/index.php?r=****/captcha&v=*****

So… we can also add the right rules like:


  public function accessRules() {

    return array(

        array('allow', // allow all users to perform 'index' and 'view' actions

            'actions' => array('create', 'welcome','captcha'),

            'users' => array('*'),

        ),

        array('allow', // allow all users to perform 'index' and 'view' actions

            'actions' => array('admin', 'delete', 'update', 'view'),

            'roles' => array('editContent'),

        ),

        array('deny', // deny all users

            'users' => array('*'),

        ),

    );

  }