yii captcha not validating properly

后端 未结 1 1607
庸人自扰
庸人自扰 2021-01-18 16:01

Im trying to add a captcha using yii to my contact form, but there is some problem with validation.

My model

class ContactForm extends CFormModel
{
          


        
1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-18 16:14

    your model is empty , because you didn't pass any value to $model->attriburtes

    Do this :

    if($_POST['ContactForm'])
    {
         $model->attributes() = $_POST['ContactForm'];
         if($model->validate())
         {
               //some code
         }
    }
    $this->render('advertise', array('model' => $model));
    

    0 讨论(0)
提交回复
热议问题