Request Widget From Other Conroller Than The View (Captcha Via Renderpartial)

Edit: after some trouble with the spamfilter (about the word ’ v a l i d a t i n g’) I did succeed to post the complete question.

Hope someone can help


Hi there,

I’m desperate what to do next because of - what I think is - a simple mistake. So I hope someone can help me.

I have a guestion about using captcha via renderPartial. I want to render a form from the the model Feedback on my frontpage, so in //site/index I:

echo $this->renderPartial('//feedback/_frontpage_form',

			array(	'model'		=>	new Feedback('insert'),    

				), true, true);

The problem is that in the way I tried I need twice the code:

public function actions()


		return array(

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







Once in the SiteController and once in FeedbackController.

When I leave out the code in SiteController I don’t get the image, because index/site/capthca?v=. does not exists. When I leave out the code in the feedback controller, I retrieve the error when posting:

CCaptchaValidator.action captcha is invalid. Cannot find a comparable action in current controller

I figured out that this is probably because I use:

echo '<div class="row">'.



		echo $form->textField($model,'verifyCode') . 

			'</div>' .

			'<div class="hint">Type aub het bovenstaande woord over.</div>'.


$this->widget in the renderPartial view, and the $this is related to the SiteController, but I can not figure out how I can print a widget from another controller.

Is this a familiar problem for others and can you please help me with this problem?

Thank you so much in advance!


Hi FOX, welcome to the forum.

You can try to set "captchaAction" property of CCaptcha explicitly.

It defaults to "captcha" action of the current controller.

But, personally I think there’s not so big a problem in repeating captcha actions in different controllers, because you can use a class based action of CCaptchaAction.

Hi Softark!

Thanks for your quick reply! I could not react earlier because of the limit of three posts for the first day. But thanks ;)

Adding the captchaAction to the widget made my day.

Topic can be closed.


Hi Reinier,

Glad to hear that. :)

BTW, you don’t have to close your topic, because someone else in the future will want to add some interesting question and/or useful tip regarding this.