ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Getting duplicate submissions from Safecracker form

January 11, 2012 2:07pm

Subscribe [2]
  • #1 / Jan 11, 2012 2:07pm

    dehuszar

    99 posts

    I’m getting strange results from two safecracker forms which are occasionally giving me several duplicate entries whose {entry_date}‘s are all posted at the same time.

    Sometimes it’s only one duplicate, sometimes it’s twelve.

    Here’s the form tag for one of the forms in question:

    {exp:safecracker channel="applications" return="jobs/index" json="yes" include_jquery="no" datepicker="no" safecracker_head="no" dynamic_title="Application for [application_first_name] [application_last_name]" preserve_checkboxes="yes" entry_id="{segment_2}" author_only="yes"}

    The two forms use different fields, and post to different channels, but the safecracker tag is pretty much the same, as are the resulting duplicates.

    Again, it’s only on a few submissions.  I have not been able to detect anything in particular about the entry contents which might cause such a problem.

    Anything jump out as to what might be causing this?

  • #2 / Jan 12, 2012 6:45pm

    Sean C. Smith

    3818 posts

    Hi dehuszar,

    What version of EE are you using? Is your form using Ajax to submit? If so could you turn off the ajax and see if you continue to get duplicate entries?

    Also you said the safecracker tag is “pretty much the same” Are there differences? Could you post the two tags? Are you using other safecracker forms on the site that are not causing duplicate entries?

    Sean

  • #3 / Jan 12, 2012 7:41pm

    dehuszar

    99 posts

    Sadly, no.  Not really.  I haven’t been able to reproduce the effect on my own whether on the devsite or the live version of site, ajax or not.  We just got a JavaScript notification system set up on the site which relies on JSON results.  The issue existed prior to implementing all of that.

    The content form is also ajaxed and doesn’t get duplicates, but it doesn’t get nearly as much traffic as the primary forms, so it’s hard to say anything definitive there.

    We’re using EE 2.3.1, and we’re using the AjaxForm library for the JSON handling.

    Here are the tags:

    {exp:safecracker channel="applications" return="jobs/index" json="yes" include_jquery="no" datepicker="no" safecracker_head="no" dynamic_title="Application for [application_first_name] [application_last_name]" preserve_checkboxes="yes" entry_id="{segment_2}" author_only="yes"}
    {exp:safecracker channel="{channels}" return="jobs/index" json="yes" include_jquery="no" safecracker_head="no" datepicker="no" dynamic_title="[resume_objective] Resume" preserve_checkboxes="yes" entry_id="{segment_2}" author_only="yes" }

    Both are using a {preload_replace:channels="channel_name"} at the top.

  • #4 / Jan 20, 2012 6:15pm

    Sean C. Smith

    3818 posts

    dehuszar,

    I’m not sure what is happening here. I’ll ping another support team member to see what they think is going on here.

    Sean

  • #5 / Jan 20, 2012 6:58pm

    dehuszar

    99 posts

    Just to be thorough, here is the jqueryForm script handling the various safecracker submissions:

    $('#publishForm').ajaxForm({
             dataType: 'json',
             success: function(data) {
                if (data.success) {
                   $.colorbox({html:"<div class='system'><h2>You successfully added / updated your entry! - Usted Ha agregado una nueva entrada!</h2><p>You will now be redirected to the Job listings page.</div>"});<br />
                   $([removed]).attr('href', '{site_url_wlc}jobs/');<br />
                } else {<br />
                   window.console.log〈data〉;<br />
                   var errors_html;<br />
                   var i=1;<br />
                   for(i in data.field_errors) {<br />
                      errors_html += '<br />
    '+data.field_errors[i];<br />
                   }<br />
                   $.colorbox({html:"<div class='system'></p><h2>Uh oh!  Your submission failed with the following errors:</h2><p>"+errors_html+"</div>"});<br />
                }<br />
             }<br />
       });

  • #6 / Jan 27, 2012 7:28pm

    Sean C. Smith

    3818 posts

    Hi,

    I have now asked a dev to take a look at your thread. Apologies for the delay.

    Sean

  • #7 / Jan 31, 2012 5:35pm

    Sean C. Smith

    3818 posts

    dehuszar,

    I checked on my request for a dev to take a look at this thread and it seems to have disappeared. I have re-issued the request. Will keep you posted as soon as I get an answer.

    Sean

  • #8 / Jan 31, 2012 8:22pm

    dehuszar

    99 posts

    Thanks for the update!

  • #9 / Feb 01, 2012 10:48am

    Robin Sowell

    13255 posts

    If you turn on debug (Firebug for example or even live headers or your debug tool of choice)- make sure you can see it post when you submit.  Then test until you get a duplicate- is it double posting there?  That would be my first guess, but lets see if we can confirm or deny it.  Make sense?

  • #10 / Feb 02, 2012 2:07pm

    dehuszar

    99 posts

    If you turn on debug (Firebug for example or even live headers or your debug tool of choice)- make sure you can see it post when you submit.  Then test until you get a duplicate- is it double posting there?  That would be my first guess, but lets see if we can confirm or deny it.  Make sense?

    Hi Robin,

    I think I understand but just to be sure, do you mean test to see if the JSON results post twice in the JS console?  I use Chrome for development, and am not super proficient with Firebug, so I’m trying to translate.  When you say post are you referring to $_POST?  It might be helpful if you can let me know how your dev tool would print out what you’re looking for me to produce.

  • #11 / Feb 02, 2012 2:23pm

    Robin Sowell

    13255 posts

    Yep- you’ve got the right idea.  OK - here’s how I do it in FF using Firebug.  Should work the same in Chrome- and here’s an easy way to see if it does.  Go to the CP’s edit page- turn Firebug on so it’s showing.  On the ‘Console’ tab with the ‘All’ option selected - then click on one of the table headers to make it sort.  And you’ll see it post- attaching an image to get the idea.

    We want to see if it’s sending that post data more than once via the JS when it’s duplicating.  Make sense?

  • #12 / Feb 02, 2012 2:26pm

    dehuszar

    99 posts

    Yup.  I’ll give it a whirl.  Thanks!

  • #13 / Feb 05, 2012 8:45am

    Sean C. Smith

    3818 posts

    dehuszar,

    Have you tried what Robin suggested? Is there anything else I can assist you with?

    Sean

  • #14 / Feb 07, 2012 2:16pm

    dehuszar

    99 posts

    Hi Sean and Robin,

    I’ve been swamped, but should be able to run some tests tomorrow.  Can you keep the ticket open till the end of the week?

  • #15 / Feb 10, 2012 5:59pm

    Sean C. Smith

    3818 posts

    dehuszar,

    No problem, just post back when you have an update and we’ll be ready to help you out.

    Sean

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases