Skip Navigation

[Resolved] In a Form to publish child posts, pre-select the parent

This thread is resolved. Here is a description of the problem and solution.

Problem:
Where a Form to publish child posts is linked to from a parent post, how to pre-select that parent in the corresponding field of the form?

Solution:
Use the wpv-post-id shortcode to set the value attribute of the cred_field shortcode that inserts the parent select field, like so:

[cred_field field='@programme-lot.parent'  select_text='--- not set ---' class='form-control' output='bootstrap' value='[wpv-post-id]']
This support ticket is created 6 years, 5 months ago. 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 5 replies, has 2 voices.

Last updated by Franck 6 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#915104

Hello,
I am surprise because my form doesn't reconize parent post anymore and i have do nothing.

You can see there : hidden link

In my form i have put this field : [cred_post_parent get='id']

Thanks a lot

#915191

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

I don't see any debug info for your site so I can't see what plugin versions you are using.

Did you recently update to Types 3.0 and Toolset Forms 2.0?

If so, did you run the post relationships migration wizard?

It may help if I can take a look at your Form and see how you have this set up, if that's okay.

Let me mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes.

Can you confirm how you link to the form and where it is displayed?

#915259

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

The account you created for me is not an admin account, so I can't see anything in the backend, and I can't see your form on the front-end either.

Also, let me repeat the questions:

Did you recently update to Types 3.0 and Toolset Forms 2.0?

If so, did you run the post relationships migration wizard?

#915525

Sorry, you are Admin now.

I create the site with the beta version so i think i don't have to run migration, no ? And if yes how i could do ?

Thanks a lot.

#915770

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

If you set this up with the betas then there is nothing you need to do, except you should keep your plugins up-to-date (Types, Views and Layouts all have updates available).

I'm not sure what your intention with the [cred_post_parent get='id'] shortcode in the form is.

I can see that you have inserted the form to publish a child Lot directly into the template for the parent Programme posts, so I assume you expect when you visit a Programme post that the form should have that Programme pre-selected in the field to set the Lot parent.

You can do that with the value attribute on the relevant field set to the current post ID (i.e. the ID of the Programme post where the form is inserted), like so:

[cred_field field='@programme-lot.parent'  select_text='--- not set ---' class='form-control' output='bootstrap' value='[wpv-post-id]']
#916989

Thanks a lot