captcha url

I’m using the captcha widget on a few different pages, but it only works on one. After viewing the page source I found that the url to the captcha image is wrong on the pages where it’s broken. Here is the relevant code I’m using:

Page url: /project/site


	public function rules()


		return array(

			// username and password are required

			array('email, password, domain', 'required'),

			// rememberMe needs to be a boolean

			//array('rememberMe', 'boolean'),

			array('email', 'email'),

			// password needs to be authenticated

			array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),







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

	<div class="row">

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


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

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


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

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


	<?php endif; ?>

I used the same code for the captcha on a controller / view whose url is: project/licensee

The url path for the ‘site’ captcha is:

<img id="yw1" src="/project/site/captcha?v=4dff904058a6b" alt="" />	

The url path for the ‘licensee’ captcha is (the image does not show up):

<img id="yw1" src="/project/licensee/captcha?v=4dff904058a6b" alt="" />	

How can I specify the image path of the captcha image?

Looks like the problem wasn’t the url to the captcha image - I was missing the ‘actions’ function from my controller:

	public function actions()


		return array(

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





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

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






The captcha image now shows up.

Besides adding ‘captcha’ to the actions(), notice that you also have to add it to the accessRules() in the controller, so that the page can render the image. You get the same symptom if either part is missing.