Issue #11 resolved

captcharow

manuel_84
created an issue

is it possible to have a captcha with showRefreshButton = true ?

Comments (11)

  1. Christoffer Niska repo owner

    Yes, but not using captchaRow. If you have an idea how to achieve this without breaking any other code please tell me. :) However, this ain't a bug so I'm closing it as invalid.

  2. manuel_84 reporter

    Hi, at the moment I solved this problem editing BootInputHorizontal.php at line 179

    		echo '<div class="widget">'.$this->widget('CCaptcha', array('showRefreshButton' => true, 'buttonType' => 'button'), true).'</div>';
    

    I think you should add options to customize this output

  3. Anonymous

    Hi, couldn't we use $data property for this ? I know this is used for list widgets, but we could do something like this :

    In BootActiveForm.php:

    /**
    	 * Renders a captcha row.
    	 * @param CModel $model the data model
    	 * @param string $attribute the attribute
    	 * @param array $htmlOptions additional HTML attributes
    	 * @param array $captchaOptions additional CCaptcha options
    	 * @return string the generated row
    	 * @since 0.9.3
    	 */
    	public function captchaRow($model, $attribute, $htmlOptions = array(), $captchaOptions=array('showRefreshButton'=>false))
    	{
    		return $this->inputRow(BootInput::TYPE_CAPTCHA, $model, $attribute, $captchaOptions, $htmlOptions);
    	}
    

    In BootInput*.php

    /**
    	 * Renders a CAPTCHA.
    	 * @return string the rendered content
    	 */
    	protected function captcha()
    	{
    		echo $this->getLabel().'<div class="controls"><div class="captcha">';
    		echo '<div class="widget">'.$this->widget('CCaptcha', $this->data, true).'</div>';
    		echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions);
    		echo $this->getError().$this->getHint();
    		echo '</div></div>';
    	}
    

    This way, just add a fourth (optional) parameter to your call to CaptaRow :

    echo $form->captchaRow($model, 'verifyCode', array('class' => 'xlarge'), array('clickableImage'=>true,'showRefreshButton'=>true));
    
  4. manuel_84 reporter

    remember to add into demo and documentation please

    actually this code don't work:

    echo $form->captchaRow($model, 'verifyCode', array('class' => 'xlarge'), array('clickableImage'=>true,'showRefreshButton'=>true));
    

    how to add html options now? this is a working complex example i'm using now:

        if (CCaptcha::checkRequirements()) {
          echo $form->captchaRow($model, 'verifyCode', array(
            'buttonLabel' => Yii::t('Register', 'Cambia codice'),
            'buttonType' => 'button',
            'showRefreshButton' => true),
          array(
            'rel' => 'popover',
            'data-title' => Yii::t('Register', 'A cosa serve?'),
            'data-content' => Yii::t('Register', '&Egrave; un modo per prevenire che utenti non autorizzati possano provare ripetutamente password per tentare di accedere agli account e/o bloccare il sito'),
            'hint' => Yii::t('Register', 'Inserire le lettere visualizzate nell\'immagine'),
          ));
        }
    
  5. Christoffer Niska repo owner

    I think we should move the captchaOptions last as suggested, it's a special case so I guess it's alright to have it as the last argument even though it's an inconsistency.

  6. Linas Jusys

    This is old, any news on this one? My captcha never passes verification... on: array('codeVerify', 'required') array('codeVerify', 'captcha') <-- if I change this to:

    array('codeVerify', 'captcha', 'captchaAction'=>'site/register'). It ignores verification at all and brings back this error:

    <h1>CException</h1> <p>CInlineAction and its behaviors do not have a method or closure named "validate". (C:\wamp\www\YiiMain\framework\base\CComponent.php:266)</p><pre>#0 C:\wamp\www\YiiMain\framework\validators\CCaptchaValidator.php(51): CComponent->__call('validate', Array)

    1 C:\wamp\www\YiiMain\framework\validators\CCaptchaValidator.php(51): CInlineAction->validate('scxca', false)

    2 C:\wamp\www\YiiMain\framework\validators\CValidator.php(213): CCaptchaValidator->validateAttribute(Object(User), 'codeVerify')

    3 C:\wamp\www\YiiMain\framework\base\CModel.php(159): CValidator->validate(Object(User), NULL)

    4 C:\wamp\www\YiiMain\framework\web\widgets\CActiveForm.php(920): CModel->validate(NULL)

    5 C:\wamp\www\YiiMain\app\sventessvesk\protected\controllers\SiteController.php(52): CActiveForm::validate(Object(User))

    6 C:\wamp\www\YiiMain\app\sventessvesk\protected\controllers\SiteController.php(82): SiteController->performAjaxValidation(Object(User))

    7 C:\wamp\www\YiiMain\framework\web\actions\CInlineAction.php(49): SiteController->actionRegister()

    8 C:\wamp\www\YiiMain\framework\web\CController.php(308): CInlineAction->runWithParams(Array)

    9 C:\wamp\www\YiiMain\framework\web\CController.php(286): CController->runAction(Object(CInlineAction))

    10 C:\wamp\www\YiiMain\framework\web\CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)

    11 C:\wamp\www\YiiMain\framework\web\CWebApplication.php(282): CController->run('register')

    12 C:\wamp\www\YiiMain\framework\web\CWebApplication.php(141): CWebApplication->runController('site/register')

    13 C:\wamp\www\YiiMain\framework\base\CApplication.php(180): CWebApplication->processRequest()

    14 C:\wamp\www\YiiMain\app\sventessvesk\index.php(13): CApplication->run()

    15 {main}</pre>

  7. Log in to comment