On my clients website that we are building in a sandbox, I have set up a many to many relationship using an intermediary custom post type. We are
using Woocommerce and the products are Machines. The two CPTs are Companies and Ownership (the intermediary post type).
(fyi but not relevant: we have injected the company and contact post types with the WooCommerce product taxonomy using code in the functions
file)
We have built 3 CRED forms, one each to add a new Machine, a new Company and a new Contact.
The Company CPT has 2 children: Ownership and Contact. The Contacts are easy: when I use the auto-generate function in CRED, it automatically adds
the drop-down to select the Company with whom the contact is associated.
In the CRED to add a Machine, even though the relationship is established in the custom post type, I cannot get the CRED to show a drop down of the
companies on the form. If I edit the Product (Machine) directly in the WordPress dashboard, I can see the post relationship and select the company
(after saving the Product first). When I manually copy the code from the ownership custom post type, I get a CRED error.
<div class="form-group">
<label>Machine Owner</label>
[cred_field field='_wpcf_belongs_product_id' value='' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Machine Owner</label>
[cred_field field='_wpcf_belongs_pm-company_id' value='' class='form-control' output='bootstrap']
</div>
Is this because the product has to be saved before the post relationship can be established?
Here are my CRED forms:
The "add a Contact" form is here:
hidden link
at the bottom of the form, you can see the option to associate the contact (child) with its parent (company). This is wonderful.
MY QUESTION:
On the "add a machine" form:
hidden link
I would like to add the drop-down to associate that machine with a Company.
How do I do that, please?