Home › Toolset Professional Support › [Resolved] Issue with relationships on a edit form inside a view loop.
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)
Tagged: Content-submission forms, Toolset Forms
Related documentation:
This topic contains 10 replies, has 3 voices.
Last updated by Jane 4 years, 1 month ago.
Assisted by: Nigel.
Nigel, I have another issue I hope you can look at, since you still have a copy of my site.
I have an Edit Form that is used in a views loop, that creates a spreadsheet, where each row is a different post. On this form I have 2 relationships, which worked great under the old relationship setup and codes.
Now if I update to the new codes, the current value does not show and all I'm getting is an empty select, with nothing to choose from.
You can find one of these views/form if you you go to any of the mens-event, then click on Edit Event - then * Edit all Final Results.
You will see the two fields that need to be updated.
Go to the form (mens-final-results-edit form id=3399)
Just remove the old code and update to the new relationship code and you will see this problem.
I'm not sure if its something wrong in my complex coding or something at your end.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I can locate the form in the backend, I'm having trouble identifying where it is used on the front-end.
In any case, I think you are affected by this issue which just arose with the parent select fields, only on post edit forms: https://toolset.com/errata/parent-post-selector-in-edit-post-form-not-working-correctly/
It's separate to the issues arising from the recent Types migration.
The devs are working on that at the moment, and we will likely need a hotfix which should be ready within a few days.
I'll advise you when that's available so that you can update and test again, and if you still have any problems I'll get more details from you.
Thanks for telling me about that new issue. (which I do have)
Unfortunately this is an older issue and slightly different.
Looking at the two issues on my site, they show a totally different select style, and yours shows the current value as my issue shows nothing.
I'm comparing the same post in different ways on my site. One just in an edit form on a page the other in an edit form in a views loop (Images attached).
Looks like a views/form conflict involving parent select field.
If your having problems finding it on all mens-event posts try this very basic 1 item link hidden link
This issue I have found is not a major issue for me now, as I have other ways around it.
Thanks for your help.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I'm still struggling to identify where exactly I'm supposed to be looking, it might help if you have a bigger screenshot to help locate that select field in the page when I'm looking at the sample link you shared last.
On that page the only place I spot what looks like a similar selector is in the form "Mens Entries - New" under the section Final Results, and the problem line would be the one highlighted in my screenshot.
Would that be right?
On my local install, the select dropdown works, inasmuch as I can search for which country option to choose. It doesn't have a pre-existing value, but that's to be expected, as this form is to publish rather than edit a post.
But that doesn't chime with your original post, where you state "the current value does not show and all I'm getting is an empty select, with nothing to choose from", i.e. you are expecting a current value, which means I should be looking at an edit form rather than a publish form.
You refer to the mens-final-results-edit-form, but that form isn't used on the link you shared in your last update (see my second screenshot).
A bigger picture screenshot would probably help a lot.
Attached are several screenshots to help guide you to the issue.
Sorry for having such a complex site and wording. Not sure how you got to what you have described,
I thought that link provided was the most direct sample to see (I guess I was wrong).
Anyways , two things I have reactivated your access in case you need to see it on my site vs your local install, and I will try again to explain where it is.
- This is available on all posts from post type mens-event sample link hidden link
- On the front end if you click on the button "edit event" a well will open and you should see something similar to screenshot "mens-event edit link"
- If you click on the button "edit all final results" you will see the next screenshot "edit form in views loop" . This is the page of the link I provided earlier.
- The other two images are the coding for the form id 3399 and view 3397. These are the only two you should be looking at. The issue is with the two relationship fields highlighted in the form screenshot, but remember this form is in the view from the view screenshot.
This sample has only 1 item in the view, other posts can have more items.
Hope this helps
p.s. YES there should be a value for name and nation.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I wasn't able to check on your own site, the link in your last reply throws up a 404, and if I try to log-in to the site (with the credentials from the other ticket) I can't, as I'm locked out by WordFence. (I suspect WordFence is responsible for the 404, too.)
So I'm limited to checking my copy of your site. Then my problem is that on the slimmed-down version of the site I installed, I simply don't see the same as in your screenshots, I can't locate the same links that you describe and don't arrive at the page you've indicated with the problem.
I think I need to take a complete copy of the site with all of the plugins etc. so that hopefully what I see corresponds with the screenshots you are sharing.
So, can we fix the WordFence problem? I'm based in Ireland, my current IP address is 86.44.178.120 (but it is not static, so it could change).
Let me set another private reply to make sure I have the correct credentials.
I'll work on it as soon as I can access your site so that I can try and make some progress.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I've tried to activate Layouts but that gave fatal errors, likely related to having only a partial copy of your site, so I've taken a full copy and am installing that to work with.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Jane
Thanks for all the details. There are problems installing the copy of your site with the Toolset Starter theme, it throws lots of errors, but—anyway—having navigated those issues and ensuring Layouts was active I was able to follow your directions to see the problem.
I tested something similar on my own site, with a child post edit form output using a View, but couldn't reproduce the problem with the parent selectors. I'm not sure whether the issue on your site involves the slightly more complex structure (the edit form in the layout isn't really a form it just has an h2 tag and that is followed by the View that outputs the edit form), or whether it arises because your site was made with Types 2 and has undergone database migrations for both Types 3.0 and 3.4.
I've passed on all of the details to the same developer who has a copy of your site to investigate the Views issues.
We will be fairly lightly staffed over Christmas, so please bear with us a while longer and I will update you again when they have been able to investigate and comment.
Meanwhile, have a Merry Christmas.
Hi Jane
This is Juan, leader of the Toolset team. Nigel is away for some days off, but I wanted to keep you posted in our progress.
As a first note, I would like to share with you hat I am personally evaluating your site and some key elements in the frontend, to minimize performance bottlenecks by improving our related code, and also by suggesting changes in your own content and structures. Your site is fairly complex, it has a huge amount of data and it seems to have gone over a number of Types relationship migrations too, as I see some of your references go back to Types before version 3. My goal is to complete a review document and share it with you, we could keep in touch and evaluate how we go over those suggestions afterwards.
This analysis is bringing some good news for you and for everyone already. We identified an expensive mechanism that was happening too often on large pages printing a lot of Types fields, like yours. After solving it, I managed to reduce the loading time for my local copy of your site by around 2 full seconds on the most stuffed pages.
Back into the topic of this ticket, I see at least two problem with this mechanism we are evaluating here. If I get this right, we have a layout designed to edit a "Mens event" post, but the actual purpose for the layout is not to do that: it lists "Mens results" that belong the currently pseudo-edited "Mens event" and offer to edit each of them. To do so, the layout does two thngs:
- Include a "fake" form to edit the current "Mens event" post, whch does not contain a form at all but a header with a link. This is needed if you do want to use the layout as an editing resource, but this is indeed a trick, and as such, probably a performance hit and evetually also a functionality problem: this "working" now does not ensure it might work afterwards, since, well, this is not a form to edit the current "Mens event" at all.
- Include a View listing "Mens result" items that are related to the currently "fake"-edited "Mens event". The View is listed as a table, and each row in the table is a form to edit the relevant "Mens result".
Let's focus on that View, and on why the selectors for the related posts in the fields for "Mens" and "Nation SC" fields are not populated.
Before we implemented many-to-many relationships in Types 3.0, those kind of fields were filled with all available options. As we only supported on-to-many relationships, a parent could have infinite children, so the selector for the parent could hold any value. With m2m, this changes, and we have restrictions for one-to-one relationships, and also when defining limited cardinality for each side of the relationships. We can no longer fill this selector with all available posts for the parent type.
To make things even more usable, we included a library to load those fields dynamically on demand, and letting visitors search by title for the desired element to set as parent. But the library is not being initialized either on your fields. Why?
Well, it seems that those forms in each row of the View table layout never worked at all. And the reason is the same as to why the library is not turning your select dropdown into an improved selector: the field is rendered outside of the form that you are printing on each row.
Because, basically, you can not have a form in ech row of a table: https://stackoverflow.com/questions/1249688/html-is-it-possible-to-have-a-form-tag-in-each-table-row-in-a-xhtml-valid-way
This means that before you upgraded Types your fields were probably well filled with options, but submitting the form for each row was not saving the post at all.
So the problem here surfaced as those dropdowns holding no value, but the actual issue here is that your forms can not properly work because table strctures can not house a form per row, and that was not triggered by our latest update: this is how HTML works and how it gets rendered by browsers.
If you want to keep the same kind of output, you probably need to create a "fake" table with containers an the right positioning styles. But if you do want to use tables, well, then there is no room for a form in each of its rows, and has never been.
I do hope this helps for now. I will take the liberty to contact you privately by email and share the document I am crafting about improving your site, once I have it completed, if you do not mind.
Juan,
I would like to thank you on providing a well detailed report. You followed my complex setup perfectly.
I never expected that the table might be a cause. Just to clarify, the use of tables is working perfectly when using all other custom field types, just not the relationship fields, when in a views loop. The selector for a relationship field does work in a table on a form, if the form is on a page by itself. You can see a sample of the nation field here hidden link
I use tables on many forms across my site, so I will adjust the forms that contain relationship fields in a views loop. Thanks for your help.
Looking forward to reading your document on the other issue.
My issue is resolved now. Thank you!