Navigation überspringen

[Gelöst] Including an "add new" option when selecting a relationship in a form

This support ticket is created vor 5 Jahren, 6 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von alexG-4 vor 5 Jahren, 6 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#1270861

I want to be able to optionally include an "Add new" link in a form associated with a relationship selection.

That way, users can either selecting an existing post for the relationship, or add a new post for the relationship - exactly as you can do within the WordPress backend!

I can easily add a link in the form, and I've figured out how to display the required 'add new' form in a bootstrap modal.

The tricky bit, which I've not tackled yet, is being able to adjust the drop-down in the original form's relationship selector to include the newly-created post, and make that the selected value.

This will be needed both for normal forms AND relationship forms.

Before working on this, I thought it worth asking whether this feature is on your development path - it seems like a very useful feature, which you've already recognised as being important for backend relationship handling: I've found that exceptionally useful in building out my own back-end data structures, so I want to be able to provide the same feature to my future users.

If this isn't on your near-term development path, do you have any tips on the best approach?

I'm assuming this is going to be a job for jQuery, right?

Thanks

Alex

#1271017

Hi, I think you'll definitely need some JavaScript and possibly jQuery to do what you're looking for. You'll have to create some kind of AJAX application that allows you post a request via AJAX and automatically create a post of some kind and return its ID. Then you'll have to inject that value into the select field along with the post title. So there are two roadblocks here:
- No Toolset APIs are involved to create the post, so I can't help you there.
- No Toolset APIs are involved to modify a post relationship field, so I can't help you there either.

I can help you implement the post relationships API if necessary to connect two posts.

I can't see this feature on our immediate schedule, though improving the post relationship Form experience is on the long-term roadmap.

#1271675

At least I know I won't be duplicating work Toolset will be doing.

Thanks, Christian.

Alex