Yii Framework Forum: Multiple submit problem in CActiveForm - Yii Framework Forum

Jump to content

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

Multiple submit problem in CActiveForm Multiple submit problem in CActiveForm Rate Topic: -----

#1 User is offline   subterana 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 31-May 12

Posted 16 July 2012 - 09:35 AM

Hi,
My problem is as follows: my form writes multiple entries in the database even after I have disabled the submit button on click. I have also tried hiding the button's div on click. I find it very strange that even if I disable the button on click, the data is doubled in the database. I think I have looked everywhere, and still haven't found a solution. This isn't a problem of multiple clicking. Based on how many drop-down lists I select in my form before pressing submit, or on how many text fields I fill in, I have noticed that more duplicate entries are written in the database. I can get up to 7+ duplicate entries in the database.
Any idea why this is happening, and how I can solve it?
0

#2 User is offline   subterana 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 31-May 12

Posted 16 July 2012 - 09:56 AM

If the last field in my form is a text field, which is required/mandatory ( as set in the model ), and I write in that field , the problem disappears in Chrome, but I get double entries in Firefox...
0

#3 User is offline   subterana 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 31-May 12

Posted 16 July 2012 - 10:10 AM

I hope this link works so you can see my _form view: http://pastebin.com/iqXtV2VY
0

#4 User is offline   subterana 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 31-May 12

Posted 16 July 2012 - 10:22 AM

The problem seems to solve itself if I disable Ajax validation... Do I need that kind of validation?
0

#5 User is offline   yogobili 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 11-July 12
  • Location:Turkey

Posted 16 July 2012 - 11:23 AM

View Postsubterana, on 16 July 2012 - 10:22 AM, said:

The problem seems to solve itself if I disable Ajax validation... Do I need that kind of validation?

If you need a client-side validation and use some autocomplete etc. things then you should use Ajax validation
0

#6 User is offline   subterana 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 31-May 12

Posted 16 July 2012 - 12:46 PM

View Postyogobili, on 16 July 2012 - 11:23 AM, said:

If you need a client-side validation and use some autocomplete etc. things then you should use Ajax validation

Well, I only have client validation enabled now, and it seems to work without Ajax validation. I don't have any auto-complete fields. I don't understand why having Ajax validation enabled causes such problems.
0

#7 User is offline   rall0r 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 165
  • Joined: 11-November 10
  • Location:Bln

Posted 17 July 2012 - 02:27 AM

Could it be possible, the your validation-code and your save-code is bundled together, so that the first DB insert happed at validation time?

Did you use firebug (or something like this) to debug how many request are fired from client? To see what is validation and what is an submitted form (in order to insert this into the DB).

rall0r
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