Skip Navigation

[Resolved] Cred shortcode for parent post doesn't work in form

This support ticket is created 6 years, 11 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 12 replies, has 2 voices.

Last updated by kirillS-3 6 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#592832
Screenshot 2017-11-24 11.29.25.png

I am trying to:

Preselect parent post by this code:

<div class="form-group" style="/*display:none;*/">
<label>appointmentslot Parent</label>
[cred_field field='_wpcf_belongs_appointmentslot_id' value="[cred_post_parent get='id']"]
</div>

Link to a page where the issue can be seen:

hidden link

I expected to see:

Preselected value in dropdown parent post list

Instead, I got:

Shortcode with parent post id inside field shortcode just broke it.
The same with input field.

You could see it in screenshot.

By the way, I copy everything to staging and disable most plugins - the problem still exist.

#592910

Nigel
Supporter

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

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

Hi Kirill

You cannot use the cred_post_parent shortcode to set the post parent in a CRED form. It is solely intended to output content about the post parent when the CRED form already knows which is the post parent.

A CRED form already knows which is the post parent if you follow the steps described in this page to create the child post link when displaying the parent post: https://toolset.com/documentation/user-guides/cred-forms-for-child-content/

So, when done correctly, the link from your parent post will add the ID of the parent post as a URL parameter like ?parent_parent-slug_id=5.

If that URL parameter is present when the child post form is loaded then the parent field will automatically be set, you don't need to intervene and use the value attribute to set it, which is what you appear to be trying to do.

If you automatically generate the form markup the parent selector field should be added with the required attributes.

Your plugins are up-to-date and it works with the current version. Remove the value attribute from the parent selector field, and if that doesn't work try regenerating the markup for the form.

#592957

Hi Nigel,

yes, it was exactly as you describe before and it works. But about week ago it stop to work as I expect and as it was before. So, I try to make it work manually by entering id in "value" field.
So, now I regenerate a form and it still does not work.
I create a new form with the same goal, but it still does not work.

URL is hidden link - so, it has exactly parameter URL as you described.

So, I still need your help to fix it

#593276

Nigel
Supporter

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

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

Hi Kirill

Could you please try a conflict test and if that doesn't reveal anything I'll get a copy of your site for further testing, because it works as expected on my own local test site with current versions.

Disable non-Toolset plugins and switch theme to twentyseventeen, then re-test the form. Does that make any difference? If it does, then there is a conflict with another plugin or your theme affecting this.

If not I need a copy of your site to work on, if you could prepare one: https://toolset.com/faq/provide-supporters-copy-site/

I'll mark the next reply as private in case you are sharing the duplicator packages with me.

#593862

Nigel
Supporter

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

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

Hi Kirill

I couldn't get past the authentication pop-up with the credentials you supplied.

If you are on WPEngine you can use the All-in-One WP Migration plugin to generate an archive instead.

I'll mark your next reply as private again so that you can share a link to the backup archive on dropbox, gdrive or similar.

#593991

Nigel
Supporter

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

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

Hi Kirill

I couldn't use the backup package you created, but in any case, looking at your site I realised what the problem is.

The last CRED update added the Select2 library on the post parent select field, to make it easier to choose the required parent when there are many (16+) possible parents to choose from.

Unfortunately that appears to have broken the functionality whereby the parent is pre-selected.

I have reported this and hopefully we will provide a solution soon as there may be quite a few sites affected by this.

#594026

Hi Nigel!

Ok, thanks for info. I really looking forward for your update to fix this bug.

#595369

Hi Nigel!

Any updates about this case?
We really need some solution to fix the bug.

#595495

Nigel
Supporter

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

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

Hi Kirill

I checked the internal tickets and see that a solution has been produced and is undergoing testing.

I've added a request to see if a hotfix can be published asap.

I'll keep you posted.

#596697

Nigel
Supporter

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

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

Hi Kirill

We are preparing an erratum with a fix for the issue, but I thought I would make it available to you so you can apply and test: hidden link

Extract the field.php file and replace the current file of the same name in the location plugins/cred-frontend-editor/application/models/field/.

I haven't tested it myself. Rename the old file rather than delete it so you can revert to it if you find this doesn't resolve the problem.

Let me know how you get on.

#598493

Hi Nigel,

Sorry, I was not online last few days and yesterday your site was on maintenance.
I would like to test this solution, I just need access to this file from my google account - I've sent you access request, please confirm it.

#598576

Nigel
Supporter

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

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

Hi Kirill

I granted access. For anyone else that reads this thread, the erratum is now published: https://toolset.com/errata/cred-parent-post-selector-is-not-populated-correctly-if-parent-post-id-is-passed-in-url-parameter-parent_post_id/

#598613

Hi Nigel,

Thanks, it works.
Please add this fix to next plugin update.

Best regards,
Kirill