Yii Framework Forum: Ajax Form Auto-Fill - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ajax Form Auto-Fill Rate Topic: -----

#1 User is offline   Ashish Tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 13-December 12

Posted 16 January 2013 - 08:27 PM

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
Thanks
Ashish Tyagi
0

#2 User is offline   PeRoChAk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 578
  • Joined: 26-November 10
  • Location:Lahore, Pakistan

Posted 16 January 2013 - 11:23 PM

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
Cheers
Perochak
Web Design - Logo Design - Application Development

My Blog | Forums Comparison
0

#3 User is offline   Ashish Tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 13-December 12

Posted 17 January 2013 - 01:15 PM

View PostPeRoChAk, on 16 January 2013 - 11:23 PM, said:

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
Thanks
Ashish Tyagi
0

#4 User is offline   PeRoChAk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 578
  • Joined: 26-November 10
  • Location:Lahore, Pakistan

Posted 17 January 2013 - 03:34 PM

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();

Cheers
Perochak
Web Design - Logo Design - Application Development

My Blog | Forums Comparison
0

#5 User is offline   Ashish Tyagi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 13-December 12

Posted 20 January 2013 - 03:36 PM

View PostPeRoChAk, on 17 January 2013 - 03:34 PM, said:

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
Thanks
Ashish Tyagi
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users