Accueil › Toolset Professional Support › [Résolu] linking parent and child forms
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)
Marqué : Content-submission forms, Toolset Forms
Documentation connexe :
Ce sujet contient 22 réponses, a 3 voix.
Dernière mise à jour par Nigel Il y a 6 années et 10 mois.
Assisté par: Nigel.
Hi there
I created a parent and child connection because there is a need to have "custom fields" available on the parent where the custom fields could be a variety of options from one entry to unlimited options.
Ie eg social media accounts and it could be one account or 5 or 10 accounts. This I did with a parent-child setup. On the post side no problem. But on Cred how do I get to show the child fields so it could be completed. I have seen a reference to " Child Post Form Link" but are not able to find how to do this.
The child en parent forms will be unique to each other.
So I have created a parent form and a child form in cred. Now how do I go about linking the two that the child knows to which parent it belongs to once both corms have been completed?
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Hi there
I understand your question to be how to set the parent post in a CRED form to publish child posts.
If you have created a parent-child post relationship and automatically generate the markup for the child form, a field to select the parent post will be included. Your users can use this to specify the parent post.
If you want the parent post to be automatically set then you create a link to the child post form from the template for the parent posts, so that when viewing a parent post a link to create a child post appears which takes the user to the page where the child CRED form is inserted, and adds a URL parameter for the id of the referring parent post which the form uses to set the parent post field.
So, add your CRED child post form to a page.
Edit the template for the parent post type.
Use the CRED Forms button to insert a cred_child_post_link shortcode, and for the parent post choose the option "Set the parent according to the currently displayed content".
Note that the parent selector field must be included in the CRED child post form, but if you don't want your users to be able to modify the choice you can simply hide it with CSS.
HI NIgel,
Thx for your promt reply. Ok is got it all to work excetp that the parent details is not pullign through. Do you do the child after the parent details has been update?
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
I'm not sure what you mean, but you may have a problem if there are lots of parent posts (i.e. more than 15).
There is a current issue which will be fixed in the next release of CRED, but in the meantime you can apply a patch as described in this erratum: https://toolset.com/errata/cred-parent-post-selector-is-not-populated-correctly-if-parent-post-id-is-passed-in-url-parameter-parent_post_id/
Does that sound like your problem? That you have lots of parent posts available to choose from?
Hi Nigel,
No, I currently only have two entries. Still in the development phase. I an not 100% sure of the workflow is if I can put it that way.
But there will be substantially more once the system has gone live.
I am not 100% sure I have done it all right. I am making some screenshots that I will include in this post
The first screenshot is of the parent page back end. (Zipy parent page screen shot)
The second is of the child page back end (Zipy child page screen shot)
The third is of the parent page front end with dummy information. (Zipy parent page front end screen shot)
the forth is of the parent cred from design view (parent CRED form backend)
The final is of the Child cred form design view (child CRED form backend)
At this stage, things are getting fuzzy. Do I first update and then go to additional information (child page) because then the form is empty and the parent link field is also empty on the child form.
I am rather sure that this is where I am missing something.
I am willing to supply the login details if ti would assist in guiding me the correct way.
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Hi there
I see a problem with your set up.
The expected context for the cred_child_link_form shortcode is the parent post that will be set in the child form.
You have inserted a form to publish a parent onto a page, and added the link to create a child post on the same page. But there is no parent post (yet) to be set in the child form.
The parent post needs to be created before the child post can be told what the ID of the parent post is.
I think you need to modify your workflow so that the user completes and submits the form to create the parent post, and then the page redirects to display that parent post, where they then see a link to add additional details. (For that you add the cred_child_link_form shortcode to the content template for the parent post.)
Hi Nigel,
You just seem to give me guidelines that confuse my l head. HEHE
Ok I did set the cred form to show the post. Then when it has made the entry, it shows I blank page except for the heading. I did create a view of the specific post even though in the cred setup I specified got to the post it shows all the posts available not just the post appropriate. To get the display I did a view of the CPT that I then used in a template.
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Sorry Andre
I did not understand your last post at all.
Do you want to give me credentials so that I can take a look at your site and try and see what the problem may be?
It would help if you could summarise just what the current problem is, e.g. "I have a CRED form to publish child posts but it does not set the parent post automatically", or is it something else?
I'll mark your next reply as private.
Hi NIgel,
I am bt worried that my last message has gone lost and i have not heard from you in almost 24 hours. (not you're the usual time frame to reply.)
Just want to make sure you did get it. (login details)
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Sorry for the delay, I had a very busy spell and have been sidelined for some of this morning with training.
I'm finishing up with that soon and your ticket is at the top of my queue so I'll get back to you soon.
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
I have looked at your site.
I see that you have:
- a parent CPT zipycard
- a child CPT zipy-content-tables
- a form to publish zipycards ("Zipy Cards")
- a form to publish zipy-content-tables which includes a parent post selector field ("Zipy Additional Information Form")
- the Zipy Cards form is added to a page ("Zipy Card Only")
- the Zipy Additional Information Form is added to a page ("Zipy Card Additional Information")
So far so good.
I then went to check the content template for zipycard posts, which is where I expected to find a cred_child_link_form shortcode that would link from the parent post to the page with the form to publish a child post (see screenshot for what the dialog looks like inserting that).
But, I found something very unexpected.
The content template "Zipy card template" used to display single zipycard posts only contains a View, and that View displays all zipy cards except for the current one.
I'm not sure what your intention is here, but when visiting a single zipycard post you surely want to display the content of that post (possibly with some additional custom fields).
So, I think you first need to edit the content template and change it so it shows the content you want from your zipycards, using the Fields and Views button to insert the post body and whatever other fields you want to include.
Then also insert the link to the CRED child form, as shown in the screenshot.
Now when you visit a zipycard post on the front end you should see the content you have set up in the template, including the link to create a child post.
When you click that link it will take you to the page with the child post form, and the parent will be automatically set.
If you don't want your users to be able to change the parent, hide that select field using CSS.
Try that and let me know how you get on.
HI Nigel,
Thx for your reply. OK is did normalize the zipy single post template and it is working perfectly. The required views with the parent and child views combined is also working perfectly.
Now my problem is still with the Cred Form. When the parent cred form is completed and submitted it is currently set to "go to the post" that then opens the zipy single post template (zipy card single).
Now obviously as this is the default template for the zipy card it would not be wise to add the cred_child_link_form shortcode to this template.
My take would be then to redirect the submit button to a page with the zipy parent view inserted with the cred_child_link_form shortcode button added to the view. However in one of your posts you said i need to use the parent post template. However i can have a template for the completed zipy card but i can not have a template just for the parent post as you can only have one template per CPT.
Last problem right now. How do i pass on the unique ref for a new zipy card (parent i just finished) to the page that contains the parent view and the cred_child_link_form shortcode" so that just the relevant parent code shows up for completion? and then second
I have for now created the following:
page 1 - Zipy Card Only Registration - For the registration form in it. (working) This opens page 2 when clicked {Source cred form "Zipy Cards" }
Page 2 - Zipy Card Parent view for updates - to view the parent entry and have the button to add the additional info in. ( need criteria as to which parent record should show) this open page 3 when clicked {Source View "Zipy view to add additional information" }
Page 3 - Zipy Card Additional Information that will open from the above one when add buton is clicked. (working) {Source "[cred_form "zipy-additional-information-form"]"}
So to recapture i just need guidance as to how do the cred form "zipy card" pass through the criteria to the Zipy Card Parent view for updates page to open the correct post.
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Hi Andre
Before we get into the details of your last update, I don't understand the obviously in "Now obviously as this is the default template for the zipy card it would not be wise to add the cred_child_link_form shortcode to this template".
What is the intended workflow for people publishing content?
Your users can publish zipycards via a CRED front-end form.
You also have a CRED form to publish zipy-content-tables.
Who is supposed to publish these and when? Under what circumstances should people be publishing these child posts?
I need to understand what you intend to happen when before I can advise you how to implement it...
Hi NIgel,
Ok the idea here is to create online business cards that will be downloadable and installed on mobile devices.
The parent is where there are fixed data on the business card. the child is s series of fields than run a a one-to-many relationship. TThe child (zipy content table) is where all of their online account details are stored. ie facebook and their facebook URL, twitter and their twitter URL etc etc. We did not want to limit the client to s specified set of fields because they may have an online shop on some platform that they may want to link to also. i.O.W there must be potential for unlimited child entries for every parent.
The client will register and given an online business card (OBC). they will then fill in the parent form and then fill in the child form. at this stage, the client will receive the url for their OBC. This is then how they will primarily distribute access to their OBC.
Because of the fact that we will look at users completing their own OBC we want to create an environment where it can be done on a front end form and not via the dashboard. Obviously, this is a small cog in a much bigger system we are developing.
I am attaching a screen print of the intended results. The buttons iin purple will basically be the child entries.
So we will not be able to ceate a page to show the zipy cards as there will be 1000's and can not create a unique page for everyone so we have to use a template to design our cards
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
OK, thanks for the clarification.
So it sounds like what you require then, is the user completes the form for the parent zipy-card and then is redirected to a page showing the form to enter a child zipy-content-tables post, and when they submit that they are redirected to the same page to be able to enter another one, repeating this until they press a different button that basically ends the process and takes them to the parent zipy-card post itself.
Does that sound right?
Note that we are basically talking about repeating field groups here, which are implemented using child posts to store one instance of a group of repeatable fields.
The UI for this will improve significantly with the new version of Types (currently in beta) and accompanying update to CRED. It will be a couple of releases of CRED before the repeating field groups UI that you can see now in the back-end with Types becomes available on the front-end with CRED, but that would mean having a single form and an "Add new" button to add more instances of the repeating fields.
In any case, if you confirm the above we can carry on with the current CRED.