Image delete incompatibility with weforms
Closed this issue · 2 comments
I have a wpuf post form that allows multiple image uploading. However, when weforms is also enabled on the site, the wpuf form seems to use the weforms javascript code for the image deletion: when you click on the trash icon when hovering over the image, the weforms event is run rather than the wpuf event.
Unfortunately, weforms uses 'data-attach_id' on the trash icon, whereas wpuf assumes 'data-attach-id' - i.e. a dash instead of an underscore.
So in the javascript, weforms uses jQuery...data('attach_id') in assets/js/weforms.js to determine the image's attachment ID, whereas the wpuf form is still using 'data-attach-id' in its template and jQuery...data('attach-id') in assets/js/upload.js. This means that weforms' image deletion function doesn't pick up the image's attach_id and the request to delete fails due to no attach_id being given: admin-ajax.php returns a 422 error.
NB I am specifically referring to the .data() attribute in the jQuery, not the variable name "attach_id" which is used in the POST object.
I believe the right place to fix this problem is within wpuf rather than weforms, since it seems wpuf defers to using weforms for the image deletion and so compatibility should be added here.
Hello @oliverhumpage,
Sorry to hear about your problem. We are using our plugin prefix wpuf
to select the fields var attach_id = $('.wpuf-image-wrap:last a.attachment-delete',$container).data('attach-id');
. Other plugin should not use this prefix.
Thanks for your reply. However, the weforms plugin does use exactly that prefix, on line 4797 of assets/js/weforms.js. I assumed from the name (and apparently shared codebase) that you developed that plugin as well?
If you didn't, then apologies and I will try to figure out how to contact weforms to fix it - please let me know either way.