我试图在 CActiveForm 中包含 yii 的 xupload 扩展我尝试遵循这个http://www.yiiframework.com/wiki/395/additional-form-data-with-xupload/ 但是我做不到。我有一个包含用户名和文件名字段的表单(允许用户上传并从视图中查看。)这是我的视图
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'form-form',
'enableAjaxValidation' => false,
//This is very important when uploading files
'htmlOptions' => array('enctype' => 'multipart/form-data'),
));
?>
<div class="row">
<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username'); ?>
<?php echo $form->error($model,'username'); ?>
</div>
<!-- Other Fields... -->
<div class="row">
<?php echo $form->labelEx($model,'attachment_photo'); ?>
<?php
$this->widget('xupload.XUpload', array(
'url' => Yii::app()->createUrl("form/uploadAdditional", array("parent_id" => 1)),
'model' => $model,//An instance of our model
'attribute' => 'file',
'multiple' => true,
//Our custom upload template
'uploadView' => 'application.views.site.upload',
//our custom download template
'downloadView' => 'application.views.site.download',
'options' => array(//Additional javascript options
//This is the submit callback that will gather
//the additional data corresponding to the current file
'submit' => "js:function (e, data) {
var inputs = data.context.find(':input');
data.formData = inputs.serializeArray();
return true;
}"
),
));
?>