Hi Asgaroth,
Thank you for this beautiful extension. I’m having an issue where after uploading the file the value is not getting updated in the DB field. I read as much post I found in this forum and exhausted. I really need your help as I have run out of all options.
My View file
<?php $form=$this->beginWidget(‘CActiveForm’, array(
'id'=>'assessment-form',
'enableAjaxValidation'=>false,
));
echo $form->hiddenField($model,‘File’,array(‘size’=>60,‘maxlength’=>255));
?>
<?php $this->endWidget(); ?>
<?php
$this->widget(‘xupload.XUpload’, array(
'url' => Yii::app()->createUrl("site/upload"),
'model' => $xuploadform,
'attribute' => 'file',
'multiple' => true,
//'formView' => 'application.views.user._form',
'uploadTemplate' => '#template-upload',
'options' => array(
'sequentialUploads' => true,
'acceptFileTypes' => 'js:/(\.|\/)(CSV|ZIP)$/i',
'completed' => 'js:function (event, files, index, xhr, handler, callBack) {
$("#Assessment_File").val(\'\'+handler.response.name + \'\' );
}'
),
));
?>
<div class="Assessment">
<?php
echo $out1;
?>
</div>
============
My controller file is as per your documentation,
public function actions()
{
Yii::import("xupload.models.XUploadForm");
return array(
'upload'=>array(
'class'=>'xupload.actions.XUploadAction',
'path' =>Yii::app() -> getBasePath() . "/../uploads/",
'publicPath' => Yii::app() -> getBaseUrl() . "/uploads",
'subfolderVar'=>'parent_id',
),
);
}
public function actionIndex() {
$this->layout='column3';
Yii::import("xupload.models.XUploadForm");
$model = new Assessment();
$xuploadform = new XUploadForm;
$template = 'application.views.assessment.index';
$user = Yii::app()->user->name;
$_userData = User::model()->with('assessment')->find("username=?",array($user));
$criteria=new CDbCriteria;
$criteria = $criteria->compare('user_id',$_userData->id);
$dataProvider=new CActiveDataProvider('Assessment', array('criteria' => $criteria));
$out1 = $this->renderPartial($template, array('dataProvider' => $dataProvider),true);
#$this->render('adjacencyGrid',array('out1'=>$out1));
$this -> render('index', array('model' => $model, 'out1' => $out1, 'xuploadform' => $xuploadform));
}
===
It just uses another view to render data where first half is Xupload and rest is populated with Assessment model filtered data,
Assessment View:
<h1>Assessments</h1>
<?php
$this->widget(‘zii.widgets.jui.CJuiButton’, array(
'name'=>'Data',
'caption'=>'Data',
'buttonType' => 'link',
//'url' => array('//JobsThroughPut/index'),
'id' => 'Data-id',
));
$this->widget(‘zii.widgets.jui.CJuiButton’, array(
'name'=>'Reports',
'caption'=>'Reports',
'buttonType' => 'link',
//'url' => array('//JobsThroughPut/index'),
'id'=>'btn-link',
));
$this->widget(‘zii.widgets.grid.CGridView’, array(
'id'=>'assessment-grid',
'dataProvider'=>$dataProvider,
'columns'=>array(
'id' => array('name' => '', 'type'=> 'raw', 'value'=>'CHtml::checkBox("checkbox-id",$checked=false,array("id"=>$data->id, "class"=>"my-checkboxes"))'),
/* 'user_id', */
'fromid',
'cc',
'created_date',
'lastupdate',
'modeType',
'File',
'Status',
),
));
?>
<script type="text/javascript">
$(document).ready(function(){
$(".my-checkboxes").bind('click', function(){
var id = $(this).attr('id');
$("#btn-link").attr('href', '../jobsPerHour/getchart/ass_id/'+id);
$("#Data-id").attr('href', '../jobsPerHour/index/ass_id/'+id);
});
});
</script>
Please help me.
Regards,
Amar.