caridy 2011-05-24 10:26:21 5493次浏览 2条回复 0 0 0

我需要写一个下拉列表.是由库中产生的.有种用法是:

public function getContactTypeOptions()
{
  return CHtml::listData($this->contactType, 'type_en', 'type');//貌似获取不到,这个用在下拉列表的值中,但是无效.
}

$model里面有外挂表:

public function relations()
{
  // NOTE: you may need to adjust the relation name and the related
  // class name for the relations automatically generated below.
  return array(
    'contactType' => array(self::BELONGS_TO, 'ContactSys', 'contact_type'),
  );
}

视图如下代码

<?php 
$form=$this->beginWidget('CActiveForm', array(
	'id'=>'ContactForm',
	'enableClientValidation'=>true,
	'clientOptions'=>array(
		'validateOnSubmit'=>true,
	),
)); ?>
<p class="note">添加联系方式</p>
<div class="row">
  <?php echo $form->labelEx($model,'contact_type'); ?>
  <?php echo $form->dropDownList($model,'contact_type',????????????这个如何获取,是从数据库中获取的($model->getContactTypeOptions()未获取到).?????????????????); ?>
  <?php echo $form->error($model,'contact_type'); ?>
</div>
<div class="row"> <?php echo $form->labelEx($model,'contact_info'); ?>
  <?php echo $form->textField($model,'contact_info'); ?> <?php echo $form->error($model,'contact_info'); ?> 
</div>
<div class="row buttons">
  <?php echo CHtml::submitButton('添加'); ?>
</div>
<?php $this->endWidget(); ?>
您需要登录后才可以回复。登录 | 立即注册