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.
Hi, I am trying to add a product as a child of a post using CRED.
The situation it is:
- I created a form for input a post (accommodation), which is a parent
- I created a form to upload a product (room) as a child of the accommodation
- I set a relationship one (accommodation) to many (product) called accommodations-tour
In the "add new room" form I put:
<div class = "form-group">
<Label> Structure </ label>
[cred_field field ='@accommodations-tour.parent 'select_text =' --- not set --- 'class =' form-control 'output =' bootstrap ']
If I upload to new product using the form, it is corretly saved.
The problme is in the relationship which is not set. The relationship field in admin edit page of the product is empty, and I have to set it manually.
I need to give this relationship automaticaly during the uploading of the product.
What's wrong or what I've to change?
This cannot be correct.
If you would have a WooCommerce product in a One To Many relationship somewhere that should be in the slug, unless edited.
This is native default of the parent selector in a Product post type that is child to another post type:
So this is ether an altered Post Type Slug, or altered Relationship slug, or not a WooCommerce product at all, but a Post type made with Types, eventually.
I tested both, a WooCommerce Product Type that is child to a Toolset Post Type and as well 2 native Post Types connected ion a Form that creates new child posts.
That works fine.
I think that form does not address the right relation, or some other issue with the form or slugs.
I would need to see this, if it persists after these steps:
- Test with Toolset only and Theme Twenty Seventeen
- Test with a Freshly generated Form
- Check the Relationship is saved properly and is using the same slugs as the form parent selector.
If then the issue persist, can you eventually provide access and links to where I can see the issue?
1. Please create a development site (starting site)
2. Please then update all Plugins, WordPress and themes
After that is done and the issue persist, please disable all Plugins but Toolset.
Then, as well, if the issue still persist, the theme.
After, if this is not solved, please let me know and share:
- the link to the exact page with issue, along with the precise steps to follow on the testing site to replicate the issue
- the link to the exact backend edit screen of that form, post type and involved fields.
If you cannot setup a Test Site you will have major problems in future to keep that Live site up and running, and eventually updates will introduce a error that breaks the site.
This happens, and can be avoided with the test instance.
Currently I was not able to see where the issue is happing exactly on the site.
Please can you share that and the eventual access to a test site?
I tryed after disable all plugin but not Toolset and woocommerce of course, and changing the theme in Twenty Seventeen.
The issue persit.
I think the problme is in the setting of the forms or relationship, because if I charge the product in backend it will be corrrecly saved and set as child of the accommodation.
The problem is only with the frontend form
Yes, I know that - you explained earlier this issue is only with the form.
I explained that the site is not using updated WordPress and other softwares, and that I would need the links to the front and backend of the related issue.
I see that the site is still outdated and I cannot find the links to the Form, the page with Form and other related content, in the previous reply.
Maybe they got stripped by the forum?
Can you provide them again if you did already, after you tested the steps I mention?
Is the form related this one?
It has no relationship selected, so it cannot work properly.
Can you edit that form and make sure it applies to the right relation, then regenerate the form?
Please also carefully check the steps here:
I included several possible solutions.
Ok, i share with you the link
- Link to the frontend form to create a new product: hidden link
- Link to the backend form to create a new product: hidden link
- Link of the post where I have to see the product added with the form linked above:
I've not set any relationship form, I've just included the code relative to the relationship in the form above ad you can see clickig on the link
<div class = "form-group"> <Label> Structure </ label> [cred_field field ='@accommodations-tour.parent 'select_text =' --- not set --- 'class =' form-control 'output =' bootstrap '] </div>
Usually we suggest to autogenerate the form which I mentioned here:
Can you please as well update the system?
Before that, we cannot be sure what we deal with.
It could be a conflict due to older bugs that are solved.
I have also issues loading the backend of that site, it is very slow and does produce lots of JS errors in the console.
Do you see this as well?
I am as well not sure if those issues are due to outdated WordPress and similar.
I suggest, to setup a test site, and update the system and then, if all is working fine, update the live site as well.
I see that you have a relationship "accommodations-product" and that is a One To Many where the many is Prodotti.
Hence, a Form that creates new Product and is autogenerated, will have a form to add a existing parent.
Can you head to Toolset > Forms and create a new form that adds new Products?
Then, auto-generate the form.
That, should now work fine.
I followed your suggestion.
All is updated, wordpress too.
I create a form for new product and I auto-generate the form.
Now , in the new form (in front-end) I'm not able to choose any parent becouse the "Parent select " doen't work good. It doesn't show me option (which is just one, "Casa Domenico")
I trid another time do deactivate all plugin and changing theme.
I find this:
- Deactivating all plugin: no change, it doesn't works.
- Changing the theme, I see the "Parent select" show me the option, but when I saved no relationship is set as before.
Plase , the site is off line, so you can tried to change what you think is needed. I'm realy need to fix this issue
So now we know that your theme breaks Toolset Forms, and likely this requires a compatibility process that involves that themes's author, do you agree?
If the Theme breaks the Form, we should ask the Theme Authors to cooperate with us an fix it, once we know why it's happening.
You use a Custom theme, we cannot support or fix such themes.
I suggest to - if your theme breaks Forms, using another.
Related to the issue:
You want to create many Products with Forms and choose each new product one parent of a certain type.
You have one relationship on this site:
It connects many products with one accommodation each.
As I show here, https://toolset.com/forums/topic/product-as-a-child-of-post-type/#post-1070011, if you now (I did that for you here hidden link) save a new Form to add products, the slug to add parents is not what you had in the first form, but instead as elaborated on the first reply shared above.
When I now insert this form to a page, and submit it, a new product should be created with a set parent.
When I tried to insert the form and create a page the website went down with a E 500.
I assume you have been working on some updates or similar, however, the Page was probably not saved.
You can try the new form with [cred_form form="create-new-product-and-assign-a-parent"], on any page, it should work.
Note that I cannot fix issues for you, instead, I can instruct you how to.
I have followed my own instructions when I did the steps above and was about to test it on your site but it went down with the E500 mentioned.
I suggest, l to try that form.
If it doesn't work, please let me know or provide a copy of the site, if the issue persist after all other plugins and themes are removed.
I as well tested this again locally, it works fine.
Hi, thank you for your help.
I find the conflict. It is not linked with the theme but with the layout.
A copied the form in this page: hidden link
If I set my custom layout "Dashboard" the new product is saved but no relationship is set.
If I set "Don't use a layout" the forms (the one i've created and the other one you have created) work good, and new product are savd and relationship is correctly set.
So, Why if I set the layout "dashboard" give me a relationship issue?
P.S. The problem about E 500 is because I worked on the website.
When you have a Post Form that creates new Child Posts by passing the parent post ID to the Form Field with the urlparam attribute, and submit the form in the front end, usually the post will be connected to the right (passed in URL param) parent.
If you use Layouts to display the form, then the value attribute of the parent post select field is not populated, only the label is, and the created Child Post is not connected.
This is a confirmed bug.
I apologize I did not connect this earlier, I see the issue now, with Layouts.
It should not even make a difference if this is a Product or not.
Simply the parent wont' work, in any post type
For now, this requires to not use Toolset Layouts on the very pages where you insert those Forms
That should solve it.
I am escalating thus to the Developers so I can update you when it's fixed.
This should be fixed, I just tested this again and I can successfully connect Posts to a parent, passing an URL attribute, when rendering the form in a Layout (Form Cell).
Thanks for your patience