Ajax Form Auto-Fill

I have read it here My link that AJAX validation is not supported on the file upload, but I want to implement very simple thing. In my form I am uploading a file and I want some of the field to be filled automatically with the name of the file and current time stamp and name of user, could any one suggest me how can I achieve that.

How can I achieve this: below are the field from my _form

Alert File: File to be upload

Title: autmatically filled with the file name

Type: User will input

File Name: should fill automatically

Created by: should be filled automatically the logged user name

create on: should be filled by current date

can you make it clear that

1 - Set them automatically before validation/saving

2 - Set them automatically before submitting form

in first case, you can do as




$model->user_id=Yii::app()->user->id;

$model->time=time();



In case second, you can do using jquery

I am looking for second option

You then need to have a jquery based settings for this.




$('#file_field').on('change',function(){

// define function to get the name of file and store it in some hidden filed for further processing

});



for others, you can use as

in controller before saving/validation function call




$model->user=Yii::app()->user->id;

$model->date=time();



Thank you very much