Home › Forums › Front-end Issues › Can't add or edit ACF Image after the form is inserted via innerHTML?
Basically, adding the image or clicking on the pencil or X icon doesn’t seem to be possible if an ACF Form has been created through innerHTML and I do not know why.
Here’s where it gets interesting. This must be the weirdest bug I’ve ever seen, not sure why this is happening. I say weird because if I FORGET to add an image, I get an option to add it only after I fail the validation, and if there is an image present, I can only delete but not edit it. Only when I delete it can I actually add it again. I can’t wrap my head around it.
* If the image is NOT present, I can’t add the image. Clicking on the Add Image button/link does nothing;
* If the image IS present, I can’t edit or remove the picture inside of the form. Pencil and X icons do nothing.
* If the image is NOT present and I fail the validation, then I can add the image. For example, if I click on submit without the image present, I’ll get the red error message. If I click on the Add Image, the window pops up fine;
* If the image IS present and I fail the validation, then I can only delete it but not edit it. The pencil icon does not work. I have to click on the delete icon, which gives me the option to add an image.
Once I manage to add an image, everything works perfectly. Form updates fine, other fields get generated fine; it’s only the image that is never able to pop up the WP modal to actually add the image in.
Any help would be appreciated.
You’re form is not being initialized properly.
There is documentation on steps you must perform when showing a form in a modal.
Oh wow, I did not know that. Thank you, I’ll try it out tomorrow and let you know how it went. Thanks John.
Oh, I didn’t know you were supposed to tap the button. Sorry John!
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We’re hard at work on ACF 6.1, and Beta 1 is now available 🚀— Advanced Custom Fields (@wp_acf) March 16, 2023
This release includes custom post type and taxonomy registration, an improved experience when selecting field types, PHP 8.1 and 8.2 compatibility, and more!
Let’s take a look 🧵https://t.co/Y0WcAT11l4
© 2023 Advanced Custom Fields.