Php renderPartial different model Yii多个模型可以工作,但不是全部

Php renderPartial different model Yii多个模型可以工作,但不是全部,php,yii,renderpartial,Php,Yii,Renderpartial,我有一个结合了许多模型的视图,我制作了一个选项卡,每个选项卡包含不同的模型 这是我在视图中的脚本 <?php $this->widget( 'booster.widgets.TbTabs', array( 'type' => 'tabs', 'tabs' => array( array( 'label'=>'Gen

我有一个结合了许多模型的视图,我制作了一个选项卡,每个选项卡包含不同的模型

这是我在视图中的脚本

<?php 
$this->widget(
        'booster.widgets.TbTabs',
        array(
            'type' => 'tabs',
            'tabs' => array(
                array(
                    'label'=>'Genset',
                    'content'=>$this->renderPartial('/ats/genset', array('model'=>new genset), true ),
                    'active'=> false
                ),
                array(
                    'label'=>'ATS',
                    'content'=>$this->renderPartial('/ats/ats', array('model'=>new ats), true ),
                    'active'=> false
                ),
                array(
                    'label'=>'UPS',
                    'content'=>$this->renderPartial('/ats/ups', array('model'=>new ups), true ),
                    'active'=> false
                ),
                array(
                    'label'=>'PLN',
                    'content'=>$this->renderPartial('/ats/pln', array('model'=>new pln), true ),
                    'active'=> false
                ),
            ),
        )
)
?>
在标签名为PLN的最后一个选项卡上,该选项卡不工作并返回如下错误

CEException 未定义属性pln.merk

在有些奇怪的地方,pln是我的模型,merk不是pln中的一个列,而是另一个模型中的ats,我根据ats制作了这个视图文件,ats中有merk列,但当我渲染的所有视图部分(如发电机组、UPS、ats)工作正常时,这就没有意义了

只有印尼国家电力公司和其他几个型号会抛出错误消息,比如他们不知何故无法识别印尼国家电力公司的型号列,而是从ats型号中读取了错误的列

编辑:

基本上,视图是由CRUD生成的,这是admin.php文件,其中包含CGridView

<?php
/* @var $this PlnController */
/* @var $model pln */

$this->breadcrumbs=array(
    'Plns'=>array('index'),
    'Manage',
);

$this->menu=array(
    array('label'=>'List pln', 'url'=>array('index')),
    array('label'=>'Create pln', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').toggle();
    return false;
});
$('.search-form form').submit(function(){
    $('#pln-grid').yiiGridView('update', {
        data: $(this).serialize()
    });
    return false;
});
");
?>

<h1>Manage Plns</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
    'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'pln-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'id',
        'siteid',
        'capacity',
        'arus_r',
        'arus_s',
        'arus_t',
        /*
        'id_pelanggan',
        'jumlah_fasa',
        */
        array(
            'class'=>'CButtonColumn',
        ),
    ),
)); ?>
ATS.php

<?php
/* @var $this AtsController */
/* @var $model ats */

$this->breadcrumbs=array(
    'Ats'=>array('index'),
    'Manage',
);

$this->menu=array(
    array('label'=>'List ats', 'url'=>array('index')),
    array('label'=>'Create ats', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').toggle();
    return false;
});
$('.search-form form').submit(function(){
    $('#ats-grid').yiiGridView('update', {
        data: $(this).serialize()
    });
    return false;
});
");
?>

<h1>Dapot</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php 
$this->widget(
        'booster.widgets.TbTabs',
        array(
            'type' => 'tabs',
            'tabs' => array(
                array(
                    'label'=>'Genset',
                    'content'=>$this->renderPartial('/ats/genset', array('model'=>new genset), true ),
                    'active'=> false
                ),
                array(
                    'label'=>'ATS',
                    'content'=>$this->renderPartial('/ats/ats', array('model'=>new ats), true ),
                    'active'=> false
                ),
                array(
                    'label'=>'UPS',
                    'content'=>$this->renderPartial('/ats/ups', array('model'=>new ups), true ),
                    'active'=> false
                ),
                array(
                    'label'=>'Rectifier',
                    'content'=>$this->renderPartial('/ats/rectifier', array('model'=>new rectifier), true ),
                    'active'=> false
                ),
                array(
                    'label'=>'Baterai',
                    'content'=>$this->renderPartial('/ats/baterai', array('model'=>new baterai), true ),
                    'active'=> false
                ),
                array(
                    'label'=>'BBS',
                    'content'=>$this->renderPartial('/ats/bbs', array('model'=>new bbs), true ),
                    'active'=> false
                ),
                array(
                    'label'=>'Inverter',
                    'content'=>$this->renderPartial('/ats/inverter', array('model'=>new inverter), true ),
                    'active'=> false
                ),
                array(
                    'label'=>'Trafo',
                    'content'=>$this->renderPartial('/ats/trafo', array('model'=>new trafo), true ),
                    'active'=> false
                ),
                /*array(
                    'label'=>'PLN',
                    'content'=>$this->renderPartial('/ats/pln', array('model'=>new PLN), true ),
                    'active'=> false
                ),*/
            ),
        )
)
?>

我已经解决了这个问题,所以我使用crud生成器创建下面的高级搜索选项代码, “model”=>$model覆盖了所需的模型,因此如果使用crud生成器,我必须删除下面的代码

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
    'model'=>$model,
)); ?>
</div><!-- search-form -->
现在我被困在查看、更新、删除中,它总是使用ats作为控制器文件中loadModel的主键标识符

您是否会发布pln视图文件,可能是ats视图文件?
$model_x=new model_x('search');
$model_x->unsetAttributes();
if(isset($_GET['model_x']))
            $model_x->attributes=$_GET['model_x'];