Yii Framework Forum: captcha related save() model problem - Yii Framework Forum

Jump to content

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

captcha related save() model problem Rate Topic: *---- 1 Votes

#1 User is offline   pootree 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 22-July 11
  • Location:Indonesia

Posted 28 July 2011 - 03:37 AM

hellowww,

im wondering why i cant save a user model in my database when i use captcha in my register form. anyone?

here is my controller:
public function actions()
	{
		return array(
			// captcha action renders the CAPTCHA image displayed on the contact page
			'captcha'=>array(
				'class'=>'CCaptchaAction',
				'backColor'=>0xFFFFFF,
			),
		
		);
	}


controller action create
if(isset($_POST['User']))
		{
			$model->attributes=$_POST['User'];
                        $model->save();



view
	
	<?php if(extension_loaded('gd')): ?>
	<div class="row">
		<?php echo CHtml::activeLabelEx($model,'verifyCode'); ?>
		<div>
		<?php $this->widget('CCaptcha'); ?>
		<?php echo CHtml::activeTextField($model,'verifyCode'); ?>
		</div>
		<div class="hint">Please enter the letters as they are shown in the image above.
		<br/>Letters are not case-sensitive.</div>
	</div>
	<?php endif; ?>


in my user model rules
	array('verifyCode','safe','on'=>'create'),
	array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),


saving is successfull without captcha, anyone?? thanks in advance :)
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,336
  • Joined: 12-October 09
  • Location:Croatia

Posted 28 July 2011 - 03:49 AM

Coul dbe that you get some validation errors...

check with errorSummary() if you already dont use it - http://www.yiiframew...rSummary-detail

NOTE: in the view... instead of extension_loaded() use CCaptcha::checkRequirements() like in the rules...
Find more about me.... btw. Do you know your WAN IP?
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