Hey Guys,
could anyone tell me whats wrong here? I tried to use the CCaptcha for the Comment part of the Blog tutorial,
but the Image is not Visible.
some Code:
Model:
comment.php
class comment extends CActiveRecord
{
/*
* const vars
*/
const STATUS_PENDING = 0;
const STATUS_APPROVED = 1;
public $verifyCode;
/**
* The followings are the available columns in table 'comment':
* @var integer $Id
* @var integer $postId
* @var integer $authorId
* @var string $title
* @var string $content
* @var integer $creationTime
* @var string $email
* @var string $url
* @var integer $status
*/
/**
* Returns the static model of the specified AR class.
* @return CActiveRecord the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'comment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
return array(
array('title','length','max'=>255),
array('email','length','max'=>255),
array('url','length','max'=>255),
array('content, email', 'required'),
array('creationTime, status', 'numerical', 'integerOnly'=>true),
array('verifyCode', 'captcha', 'on'=>'insert',
'allowEmpty'=>!Yii::app()->user->isGuest),
);
}
public function safeAttributes()
{
return array('email', 'title', 'url', 'content', 'verifyCode');
}
Comment form:
[html]
<div class="yiiForm">
<p>
<b>Leave a Comment!</b> (Fields with <span class="required">*</span> are required.)
</p>
<?php if(Yii::app()->user->hasFlash(‘commentSubmitted’)): ?>
<div class="confirmation">
<?php echo Yii::app()->user->getFlash('commentSubmitted'); ?>
</div>
<?php endif; ?>
<?php echo CHtml::beginForm(); ?>
<?php echo CHtml::errorSummary($comment); ?>
<div class="simple">
<?php echo CHtml::activeLabelEx($comment,'email'); ?>
<?php echo CHtml::activeTextField($comment,'email',array('size'=>40,'maxlength'=>255)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($comment,'url'); ?>
<?php echo CHtml::activeTextField($comment,'url',array('size'=>40,'maxlength'=>255)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($comment,'title'); ?>
<?php echo CHtml::activeTextField($comment,'title',array('size'=>40,'maxlength'=>255)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($comment,'content'); ?>
<?php echo CHtml::activeTextArea($comment,'content',array('rows'=>6, 'cols'=>50)); ?>
</div>
<?php if(extension_loaded(‘gd’)): ?>
<div class="simple">
<?php echo CHtml::activeLabel($comment,'verifyCode'); ?>
<div>
<?php $this->widget('CCaptcha'); ?>
<?php echo CHtml::activeTextField($comment,'verifyCode'); ?>
</div>
<p class="hint">Please enter the letters as they are shown in the image above.
<br/>Letters are not case-sensitive.</p>
</div>
<?php endif; ?>
<div class="action">
<?php echo CHtml::submitButton($update ? ‘Save’ : ‘Create’, array(‘name’=>‘submitComment’)); ?> <?php echo CHtml::submitButton(‘Preview’,array(‘name’=>‘previewComment’)); ?>
</div>
<?php echo CHtml::endForm(); ?>
[/html]
and CommentController:
/**
* Declares class-based actions.
*/
public function actions()
{
return array(
// captcha action renders the CAPTCHA image
// this is used by the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xB7DDF2,
),
);
}
Did anyone have an Idea whats wrong? I dont see any Issues there
Regards,
sebi