Independent Dropdown Menu

I am trying to create an independent( not reading from any other table)dropdown list.

The form shows just fine, you can also select the option. However, it when you create, the value in the database is not populated. here is the code.


<div class="row">

		 <?php echo $form->labelEx($model,'destination'); ?> 

			<?php echo CHtml::dropDownList('destination','',

		array(

			'Kampala' => 'Kampala', 

			'Arua' => 'Arua', 

			'Koboko' => 'Koboko', 

			'Yei' => 'Yei', 

			'Juba' => 'Juba', 

			'Yambio' => 'Yambio', 

			'Nairobi' => 'Nairobi', 

			'Meridi' => 'Meridi'

			), 

		array('empty' => '(Select a destination)'));?>

        <?php echo $form->error($model,'destination'); ?> 

	</div>



So you don’t want the values in your dropdown to come from the database but you want to store the selected value in it?

Currently your dropdown is not linked to a model, you might want to read up on this:

http://www.yiiframework.com/doc/guide/1.1/en/form.overview

Yes…that is why i stated them up there as a key value pair, that is id => name. When i try to link the dropdown to a model like this,




	<div class="row">

		 <?php echo $form->labelEx($model,'destination'); ?> 

			<?php echo CHtml::dropDownList($model,'destination',

		array(

			'Kampala' => 'Kampala', 

			'Arua' => 'Arua', 

			'Koboko' => 'Koboko', 

			'Yei' => 'Yei', 

			'Juba' => 'Juba', 

			'Yambio' => 'Yambio', 

			'Nairobi' => 'Nairobi', 

			'Meridi' => 'Meridi'

			), 

		array('empty' => '(Select a destination)'));?>

        <?php echo $form->error($model,'destination'); ?> 

	</div>

i get an error…see attached images with the errors and the stack trace.

i found the solution




<div class="row">

		 <?php echo $form->labelEx($model,'destination'); ?> 

			<?php echo $form->dropDownList($model,'destination',

		array(

			'Kampala' => 'Kampala', 

			'Arua' => 'Arua', 

			'Koboko' => 'Koboko', 

			'Yei' => 'Yei', 

			'Juba' => 'Juba', 

			'Yambio' => 'Yambio', 

			'Nairobi' => 'Nairobi', 

			'Meridi' => 'Meridi'

			),

		array('empty' => '(Select a destination)'));?>

        <?php echo $form->error($model,'destination'); ?> 

	</div>

all i did was change the


echo CHtml::dropDownList.... 

to


<?php echo $form->dropDownList