I'm building a small CRM for my company.
I have the custom post type COMPANIES which stores the details of associated companies.
I have the custom post type INTERVENTIONS which stores each goal to be achieved with a specific COMPANY.
Each INTERVENTION is made up of several company visits.
So
1 to many relationship between COMPANIES - INTERVENTIONS
1 to many relationship between INTERVENTIONS - COMPANY VISITS
When I insert a company visit where I have to select the post to which it refers (therefore not in the case in the add form is reached from a child link, in which case the parent post is selected automatically by Toolset) I would like to show the title of the intervention and next to it the name of the company to which the intervention refers to, as shown in the w-company.png image.
How can I achieve that? Thank you in advance
In your case, it seems you need:
- One "company" post can connect multiple "intervention" posts
- One "intervention" post can connect multiple "company" posts
If you still insist on two one-to-many relationships, here is a sandbox website: hidden link
1) Two post types: hidden link
2) Two relationships: hidden link
And describe detail for the question:
I would like to show the title of the intervention and next to it the name of the company to which the intervention refers to
Where and how do you want to show the title of the intervention and next to it the name of the company?
Hi Luon,
I set up the environment as I need it, in the sandbox website you provided.
I cannot try many to many relationship because one intervention belongs to one company only, while one company can have more than one intervention during a year.
IN the website you provided you forgot one piece of the puzzle, which is company visits, that is the focus of the problem.
If you visit the website now you'll see a list of companies. If you click on one company you can view details of that company and a list of interventions initiated for it. IF you click on one intervention it takes you to the page details, with a list of company visits for that intervention.
Clicking on the Add New Company Visit button at the bottom of the page, will take you to the add company visit form, where the parent intervention is already set, as I created a child post link. I would like for the COMPANY NAME for which the intervention refers to, to appear near the intervention, so that the person who is entering data is sure to be referring to the right intervention for the right company.
I have done below modifications in the sandbox website:
1) create a content template "interventions-information": hidden link
Display it's parent company post information:
2) Edit the post form: hidden link
add a HTML element:
a) You can display the parent_intervention_id URL parameter:
[wpv-search-term param="parent_intervention_id"]
b) And use above shortcode to display the content template:
[wpv-post-body view_template='interventions-information' item='[wpv-search-term param="parent_intervention_id"]']
Hello,
I am sorry but that's not what I had in mind... It kind of works if you are on the INTERVENTION page and click on Add New Company Visit (although I'd like it to be shown differently). I tried adding a new company visit from the menu and it's not showing anything (add-company-visit-png). I need the company name to be alongside the name of the intervention (how-it-should-be.png).
Hope I managed to explain more clearly this time.
Hello Luon,
yes, I can confirm that. However that is just part of the solution.
What I asked was for the COMPANY name to appear ALONGSIDE the name of the intervention in the dropdown menu when you select "add new COMPANY VISIT" from the main menu, NOT after having selected the intervention. In your message you are guiding me to select a specific intervention, while I am asking to have that information available when clicking on ADD NEW COMPANY VISIT from the main menu. The reason why is that if someone is already on the company page, they already have that information. However, if I try to select an Intervention from the dropdown menu, seeing just the words "New Associate" doesn't tell me what company the intervention refers to. Now that there are just two or three interventions, its no big deal. When the interventions become 100, not knowing what company each of them refers to, becomes a big problem. Hope it's more clear now.
As I mentioned above, there isn't such kind of built-in feature within Toolset Forms plugin.
You will need to pass parent "interventions" ID as URL parameter, so you can consider these:
In the "Add Company Visit" page, display a post view with custom search form:
- Query "interventions" posts
- Display the child post form link
Ok.
Can you give me time to copy whatever code I need to study from the sandbox site before you delete it?
I am in the hospital right now and cannot work on it
OK, I have updated this thread as "Waiting for feedback" status, you can update here if still need assistance for it, and you just use need to use the sandbox website login URL one time every day, so the sandbox website will keep alive: hidden link
The topic ‘[Closed] Name of relationship post alongside Post Title in pre-selected form field’ is closed to new replies.