Yii Framework Forum: How To Prevent Multiple Form Submission - Yii Framework Forum

Jump to content

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

How To Prevent Multiple Form Submission How to prevent a user from multiple submission of form, in both ajax/n Rate Topic: -----

#1 User is offline   Shahzad 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 16-March 12
  • Location:Islamabad, Pakistan

Posted 18 January 2013 - 06:10 AM

Dear Members,

Details about application:
I have a CGridView with a checkbox column. A cancel (ajax submit) button out of gridview. Now the user can select any row and press cancel button to call a controller's action.

Problem/Issue:
The issue is that, if user presses cancel button multiple times (repeatedly) before the first request has been completed, the corresponding action is also called multiple times, causing invalid entries.

Desirable Solutions:
1. Font End: To prevent users from pressing a button which has been previously pressed and previous request has not been completed yet.
2. Back End: Code the controller's action to be aware of this kind of multiple calls, and ignore if previous call was not completed.

Waiting for your replies please.
0

#2 User is offline   kokomo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 289
  • Joined: 23-July 10

Posted 18 January 2013 - 07:34 AM

I would hide the cancel button after first click and show a loading indicator or something else instead. If the action has finished show the cancel button again.
0

#3 User is offline   Shahzad 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 16-March 12
  • Location:Islamabad, Pakistan

Posted 19 January 2013 - 08:45 AM

Yes, front end solution is simple. But i am more interested in back end (controller action) solution, which is also more concerned with this forum as well.
0

#4 User is offline   kokomo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 289
  • Joined: 23-July 10

Posted 22 January 2013 - 10:46 AM

Ok, on server side you can write something to session to indicate if the cancel operation has clicked. So if the user clicks again you check the session if cancel click is allowed. If not inform the user or do nothing...
0

#5 User is offline   Shahzad 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 16-March 12
  • Location:Islamabad, Pakistan

Posted 24 January 2013 - 02:54 AM

View Postkokomo, on 22 January 2013 - 10:46 AM, said:

Ok, on server side you can write something to session to indicate if the cancel operation has clicked. So if the user clicks again you check the session if cancel click is allowed. If not inform the user or do nothing...


Oh Yes, you are right i should think it in that way. Thank you.
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