Reputation: 2256
This is YII framework and i have following table : tbl_banner_location_type
bannerLocationTypeId(PK) bannerLocationId(FK) bannerTypeId(FK)
1 1 2
2 2 5
3 1 6
Now i have bannerLocationId's value as input. i.e. 1 I want all banner type values which comes from different table. I have tried below code but getting error: Property BannerLocationType.$data->bannerType->value" is not defined.
$data = BannerLocationType::model()->findAll('bannerLocationId=:bannerLocationId',
array(':bannerLocationId'=>(int) $_POST['bannerLocationId']));
$data = CHtml::listData($data,'bannerTypeId','$data->bannerType->value');
echo CHtml::tag('option', array('value'=>''),CHtml::encode('- - Select - -'),true);
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
I know i can get it's value by following way but i want array.
$obj= BannerLocationType::model()->findByPk($id);
$obj->bannerType->value;
Please help.
Upvotes: 1
Views: 1432
Reputation: 2256
Ohhh... Issue is fixed..That was so basic.. My poor YII knowledge.
I have changed
$data = CHtml::listData($data,'bannerTypeId','$data->bannerType->value');
with
$data = CHtml::listData($data,'bannerTypeId','bannerType.value');
Sorry friends if my question was unclear. But i was not sure how do i represent this issue.
Upvotes: 4