Hi
I’m new here in Yii
Perhaps the question that I will do is very newbie or someone already did it
but here it goes
I have a CListView and wanted to show only records that have fields in a table like (id = 3) for example
instead of showing all records
the objective is to show only the records that are linked to the user
like in the pitcure the records who have id pessoa = 1
bglee
(Yii)
2
Sure. You just need to add criteria to your dataprovider. For example:
$dataProvider=new CActiveDataProvider('MyModel', array(
'criteria'=>array(
'condition'=>'user_id='.Yii::app()->user->id,
),
));
Thanks a lot, it works
I’m still trying to learn and understand the functioning of Yii
bglee
(Yii)
4
No problem. I feel like I’ve just reached critical mass. I understand enough to get some things done.
And another question
In the picture shows for example the group: 1 and raca: 1
how do I show the group name which has id = 1?
bglee
(Yii)
6
You should post your code. I believe you can get what you want by editing your ‘itemView’ file.
I already discovered how to do this
In the model I set relations, and in the file _view
I changed:
<?php //echo CHtml::encode($data->raca_id); ?>
for this:
<?php echo CHtml::encode($data->Raca->raca_nome); ?>
i found the solutions over here: