icultivator 2015-01-08 11:07:05 9058次浏览 1条评论 5 1 0

原文:http://www.icultivator.com/p/10539.html

1、在控制器中使用:

public function actionCreate()
{
    $model=new News;

    $purifier = new CHtmlPurifier();
    $purifier->options = array(
        'URI.AllowedSchemes'=>array(
            'http' => true,
            'https' => true,
        ),
        'HTML.Allowed'=>'div',
    );

    if(isset($_POST['News']))
    {
        $model->attributes=$_POST['News'];
        $model->attributes['content'] = $purifier->purify($model->attributes['content']);
        if($model->save())
            $this->redirect(array('view','id'=>$model->id));
    }
}

更多使用场景(模型、过滤器、视图)请点击:http://www.icultivator.com/p/10539.html

觉得很赞
您需要登录后才可以评论。登录 | 立即注册