lgw2008521 2011-05-05 16:30:25 3131次浏览 4条回复 0 0 0

前台-control是这样写的:

public function actionAddbuilding()
{
  $model = new Building;
  $buidinfo = new BuildingInfo; 
  $this->render('index', array(
    'model'=>$model,
    'buildinfo'=>$buildinfo,
  ));
}

前台-index.php 调用:

<div id="r_box"><?php echo $this->renderPartial('create', array('model'=>$model,'buildinfo'=>$buildinfo)); ?></div>

create.php 在building/ 目录下;是这样写的:

<tr><td><?php echo $form->labelEx($model,'building_area'); ?></td>
<td><?php echo $form->dropDownlist($model, 'building_area', Area::areas()); ?>
<?php echo $form->error($model,'building_area'); ?></td>
</tr>
<tr><td><?php echo $form->labelEx($buildinfo,'building_type'); ?></td>
<td><?php echo $form->dropDownlist($buildinfo, 'building_type', SysStatus::items('building_type_status')); ?>
<?php echo $form->error($buildinfo,'building_type'); ?></td>
</tr>
<tr><td><?php echo $form->labelEx($model,'building_price_max'); ?></td>
<td><?php echo $form->textField($model,'building_price_max',array('size'=>5,'maxlength'=>5)); ?>
<?php echo $form->error($model,'building_price_max'); ?></td>
</tr>

浏览后,执行到此处代码,就不往下显示了:

<tr><td><?php echo $form->labelEx($buildinfo,'building_type'); ?></td>
<td><?php echo $form->dropDownlist($buildinfo, 'building_type', SysStatus::items('building_type_status')); ?>
<?php echo $form->error($buildinfo,'building_type'); ?></td>
</tr>

前台显示界面: [attach]135[/attach]

帮高手帮我解答一下,谢谢

  • 回复于 2011-05-05 16:41 举报
    SysStatus::items('building_type_status')
    

    这个方法帖出来看一下!

  • 回复于 2011-05-05 18:02 举报
    public static function items($type) {
      if (!isset(self::$_items[$type]))
        self::loadItems($type);
        return self::$_items[$type];
    }
    
    private static function loadItems($type) {
      self::$_items[$type] = array();
      $models = self::model()->findAll(array(
        'condition' => 'status_type=:type',
        'params' => array(':type' => $type),
        'order' => 'status_code',
      ));
    //self::$_items[$type][0]='请选择';
      foreach ($models as $model)
        self::$_items[$type][$model->status_code] = $model->status_name;
      }
    
  • 回复于 2011-05-05 18:04 举报

    我测试过,和这个方法没关系;还是$buildinfo 模块没加上到模板的原因,但是不报错,执行到有$buildinfo 的代码,下面的就都不显示了;

  • 回复于 2011-05-06 13:50 举报

    解决了!这属于我的问题!以后要注意细节

您需要登录后才可以回复。登录 | 立即注册