ポートレットを使用して連絡先フォームを表示しています。これは、標準で生成される静的ページとまったく同じです。同じ ContactForm モデルを使用しています。フォームは表示されますが、キャプチャは表示されず、「CCaptchaValidator.action "captcha" is invalid. Unable to find such an action in the current controller.」と報告されます。
私は yii を初めて使用するので、すべてを理解するのに非常に多くの時間がかかります。それを機能させるためにシェルが行う簡単なアドバイスはありますか?
一番!
Yii::import('zii.widgets.CPortlet');
class ContactFormCard extends CPortlet
{
public $title='Contact';
protected function renderContent()
{
$model=new ContactForm;
if(isset($_POST['ContactForm']))
{
$model->attributes=$_POST['ContactForm'];
if($model->validate())
$this->controller->refresh();
}
$this->render('contactFormCard',array('model'=>$model));
}
public function actions()
{
return array(
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF,
),
);
}
}
およびポートレット ビュー:
<?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 the letters as they are shown in the image above.
<br/>Letters are not case-sensitive.</div>
<?php echo $form->error($model,'verifyCode'); ?>
</div>
<?php endif; ?>