PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

delete/edit buttons showing when loading form with ajax

  1. I am loading a gravityform with ajax after a pageload.

    After doing so my form appears, but I have these "delete" and "edit" links for each form field.

    <a onclick="StartDeleteField(this);" href="javascript:void(0);" title="click to delete this field" id="gfield_delete_1" class="field_delete_icon">Delete</a>
    <a title="click to edit this field" href="javascript:void(0);" class="field_edit_icon edit_icon_collapsed">Edit</a>

    Posted 13 years ago on Saturday June 18, 2011 | Permalink
  2. Kind of thinking this is relevant after looking at gravityform_display code ( where i found the delete link )

    http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/#comment-488

    there is a lot of IS_ADMIN which i think is what's causing my problem...

    Posted 13 years ago on Saturday June 18, 2011 | Permalink
  3. This shouldn't be happening. What you are seeing is the admin interface. How are you displaying the form? Are you using a function call directly in your theme template? What function call are you using? Provide as much details as you can for your implementation because something is wrong with how you have it implemented, the admin interface shouldn't be displaying on the frontend.

    Posted 13 years ago on Saturday June 18, 2011 | Permalink
  4. my php file included in my theme:
    http://www.chopapp.com/#zg0qjs5h

    my javascript to pull the form after page has loaded:
    http://www.chopapp.com/#4w3etqxz

    ajaxurl = wp-admin/admin-ajax.php ( as per suggested in every WP/AJAX resource I could find )

    Hope that helps - is there any other info I can provide to help?

    Posted 13 years ago on Saturday June 18, 2011 | Permalink
  5. The problem is because the ajaxurl is the admin ajax Gravity Forms thinks it's being called from the admin. That is the problem. I'm not sure of a work around to this other than not using AJAX to display the form the way you are doing it. Either don't use AJAX or find an alternative. But because you are using the admin ajaxurl, Gravity Forms thinks it's being called from the admin and therefore is displaying the admin interface.

    Posted 13 years ago on Monday June 20, 2011 | Permalink
  6. Well everywhere I've looked suggested that I must use admin-ajax.php for processing ajax requests with wordpress. So that's what I'm using. The reason I'm calling the form with AJAX is because there is currently no other way to retrieve the form without reloading the page if the form has been used. Using an AJAX form overwrites the form with a response message, and the only way to get it back is a hard-page refresh or AJAX.

    Is there a way to add/apply a filter to the gravity_form() function, perhaps letting me strip out the <a> links with preg_replace before it gets printed out? I've tried to assign it a variable and process it through preg_replace but just using gravity_form(...) causes it to print the form instead of just assign it.

    Posted 13 years ago on Monday June 20, 2011 | Permalink
  7. I'm not sure I follow what you are trying to accomplish. Why are you displaying the form with AJAX? Can you link to a page that shows us what you are trying to do visually so we know what you are trying to accomplish?

    Posted 13 years ago on Monday June 20, 2011 | Permalink
  8. I can't, its for a client, and its not ready for public consumption ><

    I'm building a web app, and I need to be able to reload the gravity_form without reloading the page. The only way to get the gravityform back after 1 submission is either AJAX or a page-refresh. And since a page-refresh is out of the question, I have to use AJAX.

    Unfortunately WP makes you use admin-ajax.php to process AJAX requests with their API, which is why I'm getting the delete/edit buttons.

    I've managed to hack the delete/edit buttons out but its definitely not foolproof/perfect.
    this is my JS function I use to (re)load the gravityform:

    function LoadPhotoForm() {
    	$.get(ajaxurl,{'action':'load_photo_form'},function(data){
    		$("#upload_form").hide().html(data);
    		$("#upload_form .field_delete_icon").remove();
    		$("#upload_form .field_edit_icon").remove();
    		$("#upload_form").fadeIn();
    	});
    }
    Posted 13 years ago on Monday June 20, 2011 | Permalink
  9. Well no, that still didn't work. Being in 'admin mode' completely changes the form functionality and now its not uploading. :/ I took off the disabled attributes from the inputs, but now when I use the form it puts it in a 'preview' mode or something, instead of actually processing it.

    I'm out of ideas to get this to work.

    Posted 13 years ago on Monday June 20, 2011 | Permalink