Yii Framework Forum: CCaptcha doesn't render refresh link - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CCaptcha doesn't render refresh link Rate Topic: -----

#1 User is offline   klaus66 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 15-October 11
  • Location:Germany

Posted 08 February 2012 - 09:53 AM

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;  
  }

0

#2 User is offline   CeBe 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 16-July 10

Posted 09 February 2012 - 05:52 AM

What is your problem? What do you expect to happen and what actually happens? Didn't get your problem...
0

#3 User is offline   klaus66 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 15-October 11
  • Location:Germany

Posted 09 February 2012 - 12:45 PM

View PostCeBe, on 09 February 2012 - 05:52 AM, said:

What is your problem? What do you expect to happen and what actually happens? Didn't get your problem...


The refresh link "Generate new image" is not rendered in the dialog form, in the contact form it is rendered.
0

#4 User is offline   CeBe 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 16-July 10

Posted 16 February 2012 - 12:33 PM

The button is added by javascript as you can see in the code here:
https://github.com/y...aptcha.php#L128

Make sure your javascript is added to html output, runs without errors and that the id used be CCaptcha is unique.
0

#5 User is offline   klaus66 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 15-October 11
  • Location:Germany

Posted 25 April 2012 - 09:26 AM

View PostCeBe, on 16 February 2012 - 12:33 PM, said:

The button is added by javascript as you can see in the code here:
https://github.com/y...aptcha.php#L128

Make sure your javascript is added to html output, runs without errors and that the id used be CCaptcha is unique.



The problem was that a second jquery script was registered.

I use now the renderBegin() and renderEnd() functions to render my form and then it works.
Annother possibility is the NLSClientScript extension to prevent more then one registration of jquery.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users