Save Button / Ajax Submission
-
Hi,
Is it possible to add a Save button to forms to Save the entered data so that the entered fields will be shown upon refresh? Or, better yet, allow Ajax submissions so that the page doesn’t refresh at all? If not Ajax, perhaps it saves it and then when the page refreshes a new section that shows the just submitted posts by the author appears with the EDIT modal button underneath it.
Is it or something similar a planned feature? Thanks.
-
Hello, thanks for reaching out! We do in fact have something like this planned in a coming update as a pro feature.
Hi,
That’s great to hear. Could you please be more specific about what the feature will be exactly? Is it ajax based or more like the other alternative I described? Also, do you have a rough ETA on when this feature might arrive? It would greatly influence my decision to buy the Pro version.
Thanks a lot. Chris.
Hello Chris, I’m glad to hear that you are interested in going pro.
We want to add ajax submit to the form, to prevent the page from having to load. It will use JS to prevent the page load and then perform all of the actions on the backend. We already have the code to do that ready to go, but the challenge we’re facing now is updating every instance of each field on the current page. This includes every instance of the post title, post content, featured image, custom fields, and more. This is quite the project and it isn’t one of those things that we can release half baked.
Unfortunately, this feature will only be available in about a month. Our goal for this is mid to late March. If that doesn’t fit your needs, I hope you find a solution that does
- This reply was modified 4 years, 9 months ago by Shabti Kaplan.
Thanks for the response. That does sound like just what I’m looking for. The timeframe is reasonable and I can use a different method for now until the update is released. When you say updating every instance, do you mean when you have more than 1 form on the same page?
The setup I’m looking for would need that. It involves a main form (for a Fan Artist custom post type) that is connected to multiple Fan Art custom post types (through an ACF Relationship field). When someone adds a new Fan Artist they can also add Content (Fan Art) but the Fan Art of course needs to be created first for it to appear in the Relationship field. The setup I have at the moment has a button with modal popup for the Fan Art form. Users can add multiple new Fan Art through this modal and then fill in the Fan Artist form with the Fan Art they added. But they have to add all the sub content (Fan Art) first and then start filling out the Fan Artist form because as each Fan Art is added the page refreshes and any data they already filled in on the Fan Artist form will be lost – so they can’t start the form, realise they need to add other Fan Art, add that, and then finish the main form and submit it. They will always have to do the main form last.
I also want the Fan Art they added to be editable after they’ve added it – this is already possible by adding a posts widget showing the latest Fan Art with a custom loop made with Ele Custom Skin (so that the Edit modal button can be shown under each Fan Art post). It would be ideal if some filter could be included to show only the Fan Art they’ve just added.
So essentially, everything is working as I want it apart from the page refreshing and the main form data being lost once any posts created from other forms on the page are submitted. Hope that all makes sense!
- This reply was modified 4 years, 9 months ago by Windurin.
Hello these forms are on the fan artist page? If so I have a solution for you. You can add a hidden acf post object field to the fan art form, and give it the default value of the fan artist post ID.
That way you might not even need the relationship field.
Alternatively, you can update the relationship field when a new fan art is added with this post ID.
For both of these, you’ll need some code.
Let me know if you need help
To answer your question, when we release the ajax feature and you create a new post, that post will indeed appear in the relationship field
Hi, Thanks for the updates. The Add Fan Art form and Edit Fan Art forms are on the same page as the Add Fan Artist page yes. It’s just one example because I also have Cosplayers, Writers, Musicians and Video Content Creators and each of those is connected to content custom post types – Cosplay, Fan Fiction, Music and Videos respectively.
The hidden field idea is clever, I hadn’t thought of that. However, I would prefer to still use the relationship fields because this isn’t the only way of adding/editing content. There are Edit forms on the individual single templates for those custom post types and Users should still be able to intuitively Remove or Add existing content that is already in the database. I have bi-directional behaviour enabled on these Relationship fields using ACF Extended so that the corresponding post is also updated.
One other custom post type I have is a Character post type and on each Character single template it shows the Fan Art, Cosplay, Fan Fiction, Music and Videos featuring that Character (5 Relationship fields on one form). This means when adding a New Character, they can also select each of those content types (other custom post types) to link to them. So you can see why having this functionality would be beneficial to me, particularly when the User needs to create new posts of those content types, ready to link to the Character.
As it is now, when the new Fan Art is added, it simply appears in the list on the left box of the Relationship field, so the User can search for and add it. If there was a way to have, for example, the just-created Fan Art automatically added into the Relationship field of the other Fan Artist form that would be even better. I’m excited by the possibilities and will certainly purchase the Pro version shortly!
Hi, I see that a Save as Draft option was added in the recent update, which may be a good temporary solution to my problem, but although I can see the Save as Draft button, I don’t see the Edit Saved Drafts option after? What are the correct setup conditions for seeing that option? Does it show up on any form you have the option enabled that you’ve used to submit Drafts? Thanks.
After playing with it some more, I’ve noticed that the Edit Saved Drafts section does show on normal Posts but not for custom post types. Are custom post types not supported with this feature?
Also, although it does saved them as drafts, when loading a draft and submitting without the Save as Draft button checked this time, it still saves as a draft.
It only shows on regular post? It should support CPTs. I’ll take a look.
Is the form also saving new posts as drafts?
Yeah, for me at least it’s only showing up when selecting standard Post as the New Port Type option. It is saving all post types as a draft successfully when set as New Post (I can see them in the backend).
After changing Posts back to a Custom Post Type, the Edit Saved Drafts section does now show but only the draft of the standard post appears in the list, not any of the draft custom post types.
The Post Status is set as Publish but with the Save As Draft option enabled, so I assume the process would be: Save as Draft, page refreshes, and I could then add any of the sub post types like Fan Art with the modal forms on the same page, and even when the page refreshes I can still select the draft from the list. But I can’t seem to get it working as intended.
Sorry, but another update: When the Save As Draft option (in the ACF Frontend Form widget settings) is enabled, it’s saving all post types as drafts even if the post status is set to Published (in the widget settings) but the Save As Draft option is NOT enabled on the form itself before submitting.
We just fixed these issues. Update the plugin and it should work
Hi. Many thanks for the quick update. Custom post types are now showing in the Edit Saved Drafts section and they are saving correctly – saving as a Draft when Save as Draft is selected and publishing when it isn’t.
The only issue I have now is some pretty strange behaviour with the ACF Relationships. Let’s say I start the main Add Fan Art Artist form, click the button to save it as a Draft and submit, then I use the Add Fan Art form modal on the same page, the just-created Fan Artist post will show up in the Fan Artist Relationship field followed by (draft).
However, if I then publish that Fan Artist by loading the saved draft from the list, and submitting the form without selecting Save as Draft, it *doesn’t* show up in the Add Fan Art modal in the Fan Artist Relationship field – even though it’s actually published. The only way for it to show up after it’s been published is a hard refresh or selecting another form from the Edit Saved Drafts dropdown. It’s not a dealbreaker issue, but I just find it strange that drafts will show up immediately after in Relationship fields of other forms on the same page, but published ones don’t. Any ideas on this?
Would the upcoming Ajax feature potentially solve this? Would any newly-created posts show up in the Relationship fields regardless of what form is selected in the Edit Saved Drafts dropdown?
The final issue is that ALL drafts posts are showing in the list now, regardless of who is using the form. In the changelog, it says that that was fixed in the previous update:
‘Tweak: limited drafts shown in new post form to those submitted by author’
Was it rolled back? Because all drafts are showing in the list for me with 2 different users, one an Admin and the other an Author.
EDIT: Sorry, I should clarify: ALL drafts are showing in the list, but if they select any draft that isn’t theirs the form is empty, but of course it would be better to only show theirs in the list.
Thanks.
- This reply was modified 4 years, 9 months ago by Windurin. Reason: Clarification
- The topic ‘Save Button / Ajax Submission’ is closed to new replies.