Hi Guys,
I have a table like so:
Products
++++++++++++++++++++++++++++++++++++++++++++
| id | name | type |
++++++++++++++++++++++++++++++++++++++++++++
| 1 | Mars | 1 |
++++++++++++++++++++++++++++++++++++++++++++
| 2 | Snickers | 1 |
++++++++++++++++++++++++++++++++++++++++++++
| 3 | Cola | 2 |
++++++++++++++++++++++++++++++++++++++++++++
I have another table like so:
Types
+++++++++++++++++++++++++++++++++
| id | name |
+++++++++++++++++++++++++++++++++
| 1 | Sweet |
+++++++++++++++++++++++++++++++++
| 2 | Drinks |
+++++++++++++++++++++++++++++++++
I am using the following code to generate a dropdown list with grouping.
CHtml::listData(Products::model()->findAll(array('condition'=>'stock_method<>3')), 'id', 'name','type')
The issue is that the options are grouped by a number rather than the type name. Is it possible to use a relationship or another find in order to show the name from the type table rather than the number in the products table?