dongluan5740 2011-07-26 04:57
浏览 9

我有问题在yii的后视图中发表评论

i want to give the comments in the views form & i follow the function..

<?php if(Yii::app()->user->hasFlash('commentSubmitted')): ?>
        <div class="flash-success">
            <?php echo Yii::app()->user->getFlash('commentSubmitted'); ?>
        </div>
    <?php else: ?>
        <?php $this->renderPartial('/comment/_form',array(
            'model'=>$data,
        )); ?>

but now it show an error.... 'htmlspecialchars() expects parameter 1 to be string, object given'

my '_form.php' under 'comment' is

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'comment-form',
    'enableAjaxValidation'=>true,
)); ?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>

    <div class="row">
        <?php echo $form->labelEx($model,'content'); ?>
        <?php echo $form->textArea($model,'content',array('rows'=>6, 'cols'=>50)); ?>
        <?php echo $form->error($model,'content'); ?>
    </div>
<div class="row">
        <?php echo $form->labelEx($model,'author'); ?>
        <?php echo $form->textField($model,'author',array('size'=>60,'maxlength'=>128)); ?>
        <?php echo $form->error($model,'author'); ?>
    </div>
  • 写回答

2条回答 默认 最新

  • doukong9316 2012-12-04 11:47
    关注

    The problem with yii's 'htmlspecialchars() expects parameter 1 to be string, object given' is that we don't know what is causing this error.

    I have made this crude change yii/web/helpers/CHTML.php: public static function encode($text) { if (is_object($text)){ echo __FILE__ ." ".__LINE__; var_dump($text); die(" This is an object, and it must be string!"); } else return htmlspecialchars($text,ENT_QUOTES,Yii::app()->charset); }

    So at least I know what object has been sent to that method.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。