Hello Everyone
I have found myself stuck trying to display my drop down list the way I want it. Basically I have 3 fields in one Table named Category…
ParentID
ID
Name
All fields are mandatory, my code atm is as so
<?php echo $form->dropDownList($model,'ParentID', CHtml::listData(ECCategory::model()->findAll(), 'ID', 'Name','ParentID' ));?>
What this does is list all the Category names under a ParentID. So for example I have
ID 9. 1. 2. 3. 4. 5.
Assuming the following Name belong the following ID’s and inside the brackets is the ParentID
Name 9.Electronics(), 1.Accessories(9), 2.Video Players(9), 3.Audio Players(9), 4.Cameras(9), 5.Headphones(1)
The Output I get now is
0
Electronics
9
Accessories
Video Players
Audio Players
Cameras
1
Headphones
What I intend to get is
Electronic
-Accessories
–Headphones
-Video Players
-Audio Players
-Cameras
I’m a little bit stuck here, I was thinking I can include a condition but how do I include a condition in a dropdownlist??
Hope this makes sense, I need a direction tbh
Regards