2014-09-17 19:42
浏览 72


I have a simple model named Service with attributes(ServiceId, name, description, Image) , and i want to display all the records in a view using CListview but only the name and description attribute, not all of them.

I am able to display the model but i cant find a solution to hide the id and image attributes.

Can anybody give a solution?

Thanks in advance.

Here is my Code :

Controller :

public function actionIndex()
    $model = new Service();


and my View:



$this->widget('zii.widgets.CListView', array(
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanjiancong4860 2014-09-17 20:37

    The answer is to change your model's view. It is propably located in protected/views/service/_view.php, where service is your's controller name.

    You can delete lines related to displaying ids and other attributes or change formatting.

    解决 无用
    打赏 举报
  • drjmrg8766 2014-09-18 05:06

    Go to your protected/views/service/_view.php Update below code

    <div class="view">
        <b><?php echo CHtml::encode($data->getAttributeLabel('name')); ?>:</b>
        <?php echo CHtml::link(CHtml::encode($data->name), array('view', 'id'=>$data->name)); ?>
        <br />
        <b><?php echo CHtml::encode($data->getAttributeLabel('description')); ?>:</b>
        <?php echo CHtml::link(CHtml::encode($data->description), array('view', 'id'=>$data->description)); ?>
        <br />
    解决 无用
    打赏 举报

相关推荐 更多相似问题