Skip Navigation

[Resolved] Cred form is not showing current child post parents in select

This support ticket is created 6 years, 1 month 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 31 replies, has 3 voices.

Last updated by katjaL 6 years ago.

Assisted by: Beda.

Author
Posts
#1137480

Can you send me access to that test site, and the link to where I can see this issue?

I will simply create a new form, to see if that solves the issue.

I assume there is some filter or similar that messes with the query.
Let's see how this looks after creating a new form.

#1138087
Die Website ist nicht erreichbar Die Server-IP-Adresse von ilmoitustaulu.annetaanilmaiseksi.fi wurde nicht gefunden.
DNS_PROBE_FINISHED_NXDOMAIN

This is the same for me and all my colleagues.

However, I saw Nigel left me a note with another URL and login, which leads to hidden link
This is not the same site.
Since you own an agency account of Toolset that is no issue but I need to know on what site I need to look for the error.
I can actually find the URL you passed on the Site I was able to log in:
hidden link

The problem is a little that I do not understand the text and it's not easy to relate.
"Yksiköt", is disabled and set to "Puusuutarin tuetut asunnot".
That should be expected because you say:

[cred-relationship-form form='harjoittelupaikkayksikot' parent_item='$current']

Since you pass the current page as the related posts, it's OK to see the exact current page as it's related post (puusuutarin-tuetut-asunnot)

If not, what should be there, and why?

"Opiskelijoiden harjoittelupaikat", shows me 2 posts, testi and testipaikka1.
This is the "child" part of the relationship form defined in [cred-relationship-role role="child"].

That is expected as well, as you did not determine a fixed child instead, have to choose it.
There are just 3 "Opiskelijan harjoittelupaikka" of which one is already used in a relation, hence cannot be offered anymore.

As far I see, everything works as expected but I might be on the wrong website...

Please do not hesitate to correct or deny my assumptions, I had currently no choice but to check the only URL I got access to.

Thank you!

#1138109

Thank you Beda, I hope your reply is/will be hidden also because of those addresses.

Now the development url should work, there was one dns missing, sorry for that.
hidden link

To summarize my problem: I want to create with a cred form a child record (opiskelijan harjoittelupaikka) belonging to the parent (yksikko, for example this puusuutarin-tuetut-asunnot) where the form is shown (yksikko content template).

Now i have auto-generated the form there. The select for choosing the parent is there in the bottom of the form, but the current parent is not choosable. Now if I just create the record without choosing any parent, the record will be parentless.

You see there is also a view (in the beginning of the page) which should show all the children belonging to this parent. So hitting the cred submit should make the just created child appear in this list. But it will not because it is parentless. It does appear in the backend (without parent). Does this clear the problem?

I obviously have something very basic wrong.

#1138145

The addresses are not public (only you, me and other Toolset Supporters can see those).

However, it is as expected, because you pass the Parent in the Form ShortCode as I elaborated here:
https://toolset.com/forums/topic/cred-form-is-not-showing-current-child-post-parents-in-select/page/2/#post-1138087
If you want to Choose the parent, you need to not pass the parent by default and instead let the user choose the parent.
This is done when you insert the Form, it will ask you what you want to do (set parents or let them choose).

You see there is also a view (at the beginning of the page) which should show all the children belonging to this parent. So hitting the cred submit should make the just created child appear in this list. But it will not because it is parentless. It does appear in the backend (without a parent). Does this clear the problem?

What you mention here is that even if a parent is selected (which it is, it is set to the current page), then the post is submitted, but not connected.

That is very similar to this BUG:
https://toolset.com/forums/topic/difficulty-storing-related-post/

But that happens only with Toolset Layouts.

May I ask permission to set up a Form similar to your on your site, so to test this on your site directly?
This, because locally I cannot replicate the problem you outline.
Note that I would need to create a new form and make a few tests submit, is this allowed?

#1138146

Thank you - yes, please do anything you need to in the dev site.

#1138179

On the test site this is different, there, you already removed the forced parent:
hidden link
hidden link

It's not the same form at all:
opiskelijan-harjoittelupaikka on the test site, harjoittelupaikkayksikot on the other.

On the test site, to create a Post (Opiskelijoiden harjoittelupaikat), that is related to the current post (Yksikkö), you can use a Post Form to create new Opiskelijoiden harjoittelupaikat and insert it.
I created this form here:
hidden link
Then, I inserted it here, but removed it later again, so you can insert it if you want:
hidden link

When you then reload for example hidden link and submit the form, setting a parent (any) it will create a Opiskelijoiden harjoittelupaikat connected to that Yksikkö.
That works fine.

You can also do that with a Relationships form, I used the existing one for this:
hidden link

However, that site is not good for tests, because some cache is stopping the pages from updating.

I could never edit the CT again after those steps above, it is now stuck on whatever version the Cache chose.
You can only solve this by saving your actual page, and that is a cache issue of the server or other plugins, this is why we do not see changes, and errors, likely.

If you want to predefine the parent, you have to either create a Link (Child Post Form Link) that leads to a page with the form and passes the ID of the parent, or, you pass the URL parameter directly in the Page/post where you have the Form, like so:
site.com/page-or-post-slug-with-form/?parent_yksikko_id=2626, where you need to pass the proper parent.

The suggested approach to this however is the child post link:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/#creating-forms-when-a-parent-post-is-preselected
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_child_link_form

This is when you use one to many or one to one relations, which you do.
If you where to use many to many, then this would apply instead:
https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/

#1138185
#1138188

Thank you Beda, there is still confusion though.

You say: "It's not the same form at all:
opiskelijan-harjoittelupaikka on the test site, harjoittelupaikkayksikot on the other."
Yes these are different forms. I am now trying to solve the opiskelijan-harjoittelupaikka issue. The harjoittelupaikkayksikot has similar problem, it will be solved, when the first one is. Sorry for being unclear.

You say: "When you then reload for example hidden link and submit the form, setting a parent (any) it will create a Opiskelijoiden harjoittelupaikat connected to that Yksikkö.
That works fine." Yes. But the current parent post is not there to choose. This is the excact issue and problem here. When I am at "puusuutarin..." page, I want to add as parent the "puusuutari.." yksikkö. But i can't choose that, because it's not there to be chosen. I'm starting to think I misunderstand something very deeply.

My current db structure is: one (parent, yksikko, "puusuutari..") to many (child, opiskelijan-harjoittelupaikka) and I'm trying to create these child records in parent single view page. But I only get to choose other parents, not current one. What am I doing/understanding wrong here?

#1138191

Yes, that is not possible as elaborated, you would need to EITHER pass a URL parameter to the very "puusuutarin" page, like ?parent_yksikko_id=2626.
That would then populate the parent Field in the Form with the yksikko post 2626.
Or, you create a Child Link, where you pass that parent:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/#creating-forms-when-a-parent-post-is-preselected
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_child_link_form

The exact approach of passing the parent to the very form is not possible, that is why I added the feature request to be voted by users and evaluated by developers for implementation.

#1138194

But please Beda, if I see all the other parents in the form select field, why not the current one? For which I want to create the child. I must have something wrong :D.

#1138236

Well I suppose I have to figure out another way to do this. Thanks anyway, a bit weird feature, but perhaps it's some kind of mis-setup on my part.

#1138834

I must solve this, because it's really needed and it has been solved before.

Here is another same situation from Jan 2018: https://toolset.com/forums/topic/child-cred-form-on-parent-post/

But I can't make it work on my site with latest toolset code.
Please help me, I'm losing my marbles here 🙂

#1138863
Bildschirmfoto 2018-11-02 um 08.16.22.png
Bildschirmfoto 2018-11-02 um 08.15.19.png

But I see it, please consult this screenshot.

Also, when submitted, the post created has that parent set.

It might be that the parent_id that was inserted in the Forms' ShortCode (and which is not supported) has broken the form.

I am sorry that I confused you previously, of course, if you have a Form that submits new Child Posts and do not restrict the parent selector, then all those should be possible to choose (which to me, seems to work fine!)

Can you try again to connect the new post created by the form?
hidden link

For me, this works.

I hope I did not miss anything.

#1138894

The hardness of this is a mystery!

Again: The parent is not there in the select form. All the other parents are. If I start to write the parent, it appears into the select form and then I can select it. And yes, then also the parent is chosen and attached as parent to this new born child. But that can't be the way you suggest I do it 😀

Please understand me now.
ISSUE 1: My first goal is this: no force to choose the parent, it would be assigned automatically or at least pre-selected. Then I could hide the whole selecting of parent.
ISSUE 2: if first issue is not possible (and why isn't it???), then at least the parent should be available there in the select (preferably first) without having to write it first in the field. (It's not something the visitor should be forced to do, they have no clue of what is whose child etc.)

#1138937
Bildschirmfoto 2018-11-02 um 12.07.13.png

As I said, Katja, it is not possible.

1. You can FORCE a Parent Post so NOTHING needs to be done by the user who submits the form, BUT:
- you can do that only if the page or post where the form is, has a URL parameter as ?parent_yksikko_id=2626 for example.
- that is usually done by inserting a Create Child Post Link somewhere, which leads to that page or post, where the form is added.
I elaborated this here:
https://toolset.com/forums/topic/cred-form-is-not-showing-current-child-post-parents-in-select/page/2/#post-1138179
https://toolset.com/forums/topic/cred-form-is-not-showing-current-child-post-parents-in-select/page/2/#post-1138191
In your case this is not a solution as you do not link from anywhere, you just want the parent set by the current post where the form is. But that is not possible unless above is done.

2. For making this possible the feature request is filed here:
https://toolset.com/feature-request/allow-to-set-par…rm-not-as-a-link/
https://toolset.com/feature-request/?wpv_post_search=Allow+to+set+parent+posts+in+Child+Post+Forms+in+a+ShortCode+attribute+of+the+form%2C+not+as+a+link&wpv_sort_orderby=post_date&wpv_sort_orderby_as=string&wpv_view_count=686737

3. Currently, you can let the user choose the parent. Since 10 by default are displayed, you do not see the very post at first but need to type.
Then you select it and submit, which connects the post.

4. In a Post Form of a Child Post Type in a One to Many Relation where you add "Many" part, the parent post selector can be customized (see screenshot).
This allows you to show only parent posts of the current author or not, and order them by certain settings.
Also, you can listen to an URL argument and that is the same as #1.
For example, you could insert there "parent_id" and then pass a ?parent_id=123 to the URL of your YKSIKKO post where the form is, then, that form would have only ONE parent post in the select field (preset) determined by that URL parameter.

But, how to pass that URL parameter to the post?
You can do that only by linking to it from somewhere else and already appending the parameter there.
Or, maybe with some JS, however this custom code kind is not part of the support.
Natively, you would add the explained "Create Child Link" as provided by Toolset, on that post, and link to a Page where the Form is, not include the form in the very post.

This is the only solution inbuilt for this.
So you would have to remove the Form and insert it to a page.
Then, insert the Create Child Post Link in the template and use that to create the child posts.

With the Relationship forms instead you can only CONNECT existing posts, not create new ones, that is why it will not work to create a new child, instead here you would have to first create the child, then redirect that to a page with the relationship form and there, connect the new child to the parent you want.