Hello guys! I've been exploring Yii for about three hours and I can proudly say that I now understand the framework much better when it comes to parameters and so on. I create a method in the model, which extracts cities(from table "cities") in DB, using custom query. Then, I have the same method in the controller, so that I can call it for example on actionCreate. I am passing the result array with cities to the create View and it passes it as an argument to the _form.
I saw a topic, create by another person, here on the forum, from where I got the idea for cHTML :: listData
This is my result.
<?php //echo CHtml::activeLabelEx($userfirms,'CITY_ID'); ?> <?php //echo CHtml::activeTextField($userfirms,'CITY_ID'); //print_r($cities); ?> </div> <div class="simple"> <?php echo CHtml::activeLabelEx($userfirms,'CITY_ID'); ?> <?php echo CHtml::activeDropDownList($userfirms,'CITY_ID', CHtml::listData($cities, 'CITY_ID', 'TITLE'), array('size'=>1, 'width'=>50)); ?> </div>
I dunno why it behaves this way. If I use just $cities, the result is awful, but it tends to work.
I mean, each option is created twice, once containing the ID, second time containing the value(title) of the city.
What am I missing?
Penko