php - Yii Captcha error -


i working in yii , beginner , trying best learn framework , here stuck @ :

i have created user model , required forms go it, , trying implement captcha :

this validation rules in user model :

$public verifycode  public function rules()     {         // note: should define rules attributes         // receive user inputs.         return array(             array('username, password, email', 'required'),             array('username','unique'),             array('email','email'),             array('verifycode', 'captcha', 'allowempty'=>!ccaptcha::checkrequirements()),             array('username, password', 'length', 'max'=>45),             array('email', 'length', 'max'=>100),             array('active', 'length', 'max'=>1),             array('created_on, updated_on', 'safe'),             // following rule used search().             // please remove attributes should not searched.             array('id, username, password, email, created_on, updated_on, active', 'safe', 'on'=>'search'),         );     } 

and overriden action() in usercontroller :

public function actions(){         return array(         'captcha'=>array(             'class' => 'ccaptchaaction',             )             );     } 

and view file :

<?php if(ccaptcha::checkrequirements()): ?>     <div class="row">         <?php echo $form->labelex($model,'verifycode'); ?>         <div>         <?php $this->widget('ccaptcha'); ?>         <?php echo $form->textfield($model,'verifycode'); ?>         </div>         <div class="hint">please enter letters shown in image above.         <br/>letters not case-sensitive.</div>         <?php echo $form->error($model,'verifycode'); ?>     </div>     <?php endif; ?> 

according me, think doing correctly however, captcha image not getting generated. oh , yes gd library installed , if navigate site/contact, there captcha generated fine.

i dont seem understand, getting wrong.

this thing see :

enter image description here

the forms seems working fine however, cant see the captcha image.

any appreciated.

regards,

i got answer, because of access rules defined in controller, had modify controller accesscontrol :

public function accessrules()     {         return array(             array('allow',  // allow users perform 'index' , 'view' actions                 'actions'=>array('index','view','captcha'),                 'users'=>array('*'),             ),             array('allow', // allow authenticated user perform every action                 'actions'=>array('create','update','admin','delete'),                 'users'=>array('@'),             ),              array('deny',  // deny users                 'users'=>array('*'),             ),         );     } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -