I have a problem with the refresh link in my form.
I use the captcha in my contact form and there it works fine.
In annother form it don’t render the refresh link. The view code for the captcha is the same as in the contact form.
<?php if(CCaptcha::checkRequirements()): ?>
<div class="row captcha">
<?php //echo $form->labelEx($model,'verifyCode'); ?>
<div>
<?php $this->Widget('CCaptcha'); ?>
<?php echo $form->textField($model,'verifyCode'); ?>
</div>
<div class="hint"><?php echo yiiparam('captchaHint'); ?></div>
<?php echo $form->error($model,'verifyCode'); ?>
</div>
<?php endif; ?>
This form is shown in a juiDialog. I think that must be the problem.
This is the js code in the view call the form:
//this function is called from the link or button
function showAdRequestForm() {
$.ajax({
url: base_url+'/ad/adrequest',
data: $(this).serialize()+'&requestType=adrequest&adId='+ <?php echo $model->id;?>,
type:'post',
dataType:'json',
success:adRequestSuccess
});
$('#dialogAdRequest').dialog('open');
return false;
}
This is my controller action code:
/**
* Send an email to the advertiser or a violation email to the webmaster.
*/
public function actionAdRequest(){
$model=new AdRequestForm();
$model->requestType=$_POST['requestType'];
if(isset($_POST['AdRequestForm'])) {
$model->attributes=$_POST['AdRequestForm'];
if($model->validate()) {
$msg_error='Ihre Anfrage konnte nicht weitergeleitet werden';
$msg_success=$model->requestType=='adrequest'?'Ihre Anfrage wurde an den Anbieter weitergeleitet': 'Ihr Anliegen wurde an den webmaster von'. Yii::app()->name. ' weitergeleitet.';
//We send the email to the advertiser
if($model->sendRequest($_POST['adId'])){
$msg=$msg_success;
}
else {
$msg=$msg_error;
}
echo CJSON::encode(array(
'status'=>'success',
'div'=>$msg
));
exit;
}
}
$div=$this->renderPartial('_form_dialog_request', array('model'=>$model), true);
echo CJSON::encode(array(
'status'=>'failure',
'div'=>$div));
exit;
}