Yii Index View Data Rendering With Condition

假如想象 提交于 2019-12-20 07:10:52

问题


I am new to yii framework i have created an yii web application with one module . Now my question is i have added an sample data into my module in my module i have an columns name,dept and and active ,i want to render the data in the grid view only the data where active=0 , Can anyone help me how to change the data rendering query and how to add the condition

<div class="block">
<div class="content">
    <h2 class="title">Users's details</h2>
    <div class="inner">
        <?php $this->widget('zii.widgets.CDetailView', array(
            'data' => $model,
            'attributes' => array(
                'user_id',
                'user_name',
                'userpass',
                'userdept',
                'active',
            ),
            'itemTemplate' => "<tr class=\"{class}\"><td style=\"width: 120px\"><b>{label}</b></td><td>{value}</td></tr>\n",
            'htmlOptions' => array(
                'class' => 'table',
            ),
        )); ?>
    </div>
</div>

Thanks in advance.


回答1:


Try adding a criteria

$criteria->compare('active', '1');



回答2:


You have to add this in your search function:

$criteria->compare('active', '1');


来源:https://stackoverflow.com/questions/15240588/yii-index-view-data-rendering-with-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!