Tell us what you are trying to do?
I have a view of business card designs that are in progress. You can see the current design of the front and back of each card, and clicking on a card opens a modal with a form with allows you to edit the card, upload images using the wp.media uploader. See attached. When you submit the form it should refresh the specific card design with the new imagery without reloading the whole page.
I have achieved most of it by having a view with a cred form in the loop. The form contains both the card design in view mode as well as the card edit form (following advice on other support threads) in a bootstrap modal. The edit form is set to use ajax and keep displaying the form after submit.
This works great, the first time you upload an image, select it in wpmedia and submit the cred form. The card edit bootstrap modal closes and the underlying card design refreshes with the new imagery. However if you try to edit the card a second time and upload an image, it doesn't work. The wp.media gallery upload works fine, but the hidden input that stores the attachment value doesn't update, and I can't see any change events being fired on that input.
Is there any documentation that you are following?
There is very little documentation in the WP Codex https://codex.wordpress.org/Javascript_Reference/wp.media
There are other examples of how to implement your own media uploader, but because I am using Toolset, I'm hoping not to go down that road.
What i have noticed is that the wp.media frame persists after the form is submitted, so I'm wondering if the frame as lost its bind with the underlying hidden input? I have been trying to reference the frame in javascript to see if i can reset where the uploader sends the attachment data on select, and set it back to the correct input.
Is there a similar example that we can see?
Not that I can find.
What is the link to your site?
hidden link
Hello,
The problem you mentioned above is abnormal, please check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/
2) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/
3) In case it is a compatibility problem, please deactivate all other plugins, and switch to WordPress default theme 2022, deactivate all custom PHP/JS code snippets, and test again
4) If the problem is fixed, activate other plugins/theme one by one, try to locate the problem plugin/theme
Hi Luo,
I did as you suggested, no errors and no change. I'll try create a simple form that loads in a bootstrap modal and ajax submits, and see what happens.
Any other ideas welcome.
Ok, I created a new view, just with a cred form in the loop, with the default formatting of a test edit form for the card post type. I set the form to use ajax, the wp media library manager is selected. No modal implemented.
Only toolset plugins active and twentytwentythree theme.
Still exactly the same issue. First time, the image saves correctly. After form submit, I try to replace the image, nothing happens.
No js errors, no php errors in debug log.
Please follow our document to setup a content template + editing post form:
https://toolset.com/course-lesson/front-end-forms-for-editing-content/
I have tried it in a fresh WP installation + the latest version of Toolset plugins, it works fine. See below test site:
Login URL:
hidden link
1) Editing post form with featured image + custom image field:
hidden link
2) Content template, display above editing post form:
hidden link
3) Post view, with above editing post form link:
hidden link
Test above view in frontend:
hidden link
For example:
hidden link
It works fine, I can replace both images correctly. For your reference.
Hi Luo,
I'm not sure if something broke since you posted your solution, but it doesn't work for me and doesn't appear to work anything like mine.
I see a post loop with 1 item, Hello World in it, I see a cred form in admin but nowhere is this displayed on the front end..
Sorry, I have added the the edit form link into view's loop:
hidden link
[toolset-edit-post-link content_template_slug='edit-post-content-template' target='self']Edit[/toolset-edit-post-link]
Please test again, it work fine now:
hidden link