du3979 2012-11-19 06:36
浏览 55

使用xupload时,_form中有两个模型,错误未定义变量

 Controller : 
 Yii::import("xupload.models.XUploadForm"); //enciora
            $photos = new XUploadForm;
 $this->render('create', array(                    
                'model' => $model,
                'photos' => $photos
            ));

 create: <?php echo 
 $this->renderPartial('_form', 
    array(
        'model'=>$model,
        'photos' => $photos
        )); ?>

_form:  <?php
        $this->widget( 'xupload.XUpload', array(
            'url' => Yii::app()->createUrl( "/encionmentDetail/upload"),
            //our XUploadForm
            'model' => $photos,
            //We set this for the widget to be able to target our own form
            'htmlOptions' => array('id'=>'encionment-detail-form'),
            'attribute' => 'file',
            'multiple' => true,
            //Note that we are using a custom view for our widget
            //Thats becase the default widget includes the 'form' 
            //which we don't want here
            'formView' => 'application.views.encionmentDetail._form',
            )    
        );
        ?>

ERROR: Undefined variable: model or Undefined variable: photos . this are the errors coming
while creating. if one model is passed then it shows properly. Please help

Well, the problem is with this line 'formView' => 'application.views.encionmentDetail._form'

. if i remove this line then no error. what should i do ?

  • 写回答

4条回答 默认 最新

  • doutangdan3588 2013-03-08 22:28
    关注

    This could well be due to the fact that your _form and your inner form for

    'formView' => 'application.views.encionmentDetail._form', 
    

    are the same. Use a different one in the form view. Its kind of getting recursive.

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题