I have a Problem when creating dropDownList in form. my code is ::
<?php echo $form->labelEx($model,'company_id'); ?>
<?php echo $form->dropDownList($model,'company_id',CHtml::listData(CompanyDetail::model()->findall(),'company_id','company_name'),array('prompt'=>'Select Company')); ?>
<?php echo $form->error($model,'company_id'); ?>
when i write this code then from that field nothing to display.
even if there no records in the database, it should still display a select box with an empty prompt
// you could replace your code with this just to debug
<?php echo $form->labelEx($model,'company_id'); ?>
<?php $options = array('company1', 'company2'); ?>
<?php echo $form->dropDownList($model, 'company_id', $options, array('prompt'=>'Select Company')); ?>
<?php echo $form->error($model,'company_id'); ?>
Sorry to hijack the thread but would you happen to know what the difference is between "prompt" and "empty"? They seem to function the same when strings are passed, but "empty" also accepts key=>value arrays with options that do not get selected when an existing key value is passed.