Listbox multi-select TV issue

Summary

A multi-select listbox TV that has been working perfectly fine for months and has suddenly stopped working. The input is not saved. This behavior appears to affect new resources only.

The TV is set up in a straightforward way:

Input options: Listbox (Multi-Select)

Dropdown list options: General||Item 1||Item 2||Item 3||Item 4

Allow blank: No

Stack selected items: No

Preserve entry order: No

List header: [blank]

Output options: Delimiter

Delimiter: ,

Template access: [The correct template is selected]

Step to reproduce

  1. A new resource is created inside the container, and the desired/appropriate template is selected.
  2. All required information is entered, and this TV, which is the only one associated with this template, is also completed (an option from the dropdown is selected).
  3. The resource is saved (CMS message: ā€œSuccess! Save successfulā€)
  4. When I click the ā€œCloseā€ button, I receive the pop-up, ā€œYou have changes pending; are you sure you want to cancel?ā€ If I save again, then try the ā€œCloseā€ button, this message appears again. If I say ā€œYESā€ and close the resource, then reopen it, the TV selection is no longer present and I must select it again and save it again, but the TV input is not saved.

I have checked inspector to see if there’s potentially anything going on under the hood and it indicates the TV data is being captured and saved. No error messages that I can find anywhere.

Observed behavior

In this example, the resources with the problematic TV are ā€œnews articles.ā€ These news articles are attached to book titles, each of which has its own unique page. (So, when I view a book page, I expect to see relevant news articles that have been tagged with this book using the TV in question.) For older news articles, this works as intended and as it always has. New ones, however, do not appear, which substantiates that the TV input is not being saved for some reason.

Expected behavior

All news articles that have an association with a specific book title should appear on the page dedicated to that book.

Environment

MODX 3.1.2; Apache 2.4.65; MySQL 10.5.25-MariaDB-cll-lve; PHP 7.4

I’m using Chrome 141.0.7390.55 (Official Build) (64-bit)

All Extras are up-to-date. Extras installed: BreadCrumb, Canonical, CodeMirror, FormIt, getResources, If, Redirector, Typography, Updater

Do you have HTML tags (characters <, >) in these options?

There have been problems with the multi-select listbox and HTML in the options since a recent change:

No, definitely not. I never did, but I also came across that issue while researching this bug. I wish it were that obvious!

TV values are stored in the database table modx_site_tmplvar_contentvalues. So after you clicked the ā€œSaveā€ button in a new resource, there should be an entry in this database table with tmplvarid = ā€œID of the TVā€ and contentid = ā€œResource-IDā€. Does such an entry exist?

Are you sure that you can change the TV-value of an existing resource and only new resources are affected by this issue?


Do you have any other ā€˜uncommon’ characters in this list of options?


Did it work fine with MODX 3.1.2 for months, or did you upgrade the MODX version recently?

I wondered about this. There are single quotes (apostrophes) and colons. But, again, this works fine with any of the resources that are older than two days ago. Granted, this is the first time I’m trying to add new ones since the upgrade to 3.1.2, but how would that impact this? (I have other sites that have the same type of TV and have been upgraded to 3.1.2 without any issues.) So, it must be something unique to this somehow.

I’ve even tried edited older resources, saving them, and removing the TV selection and re-selecting it and saving it again and it works fine. It’s only the newer objects that are fussy.

I will check the database to see if these are being written in…

Can confirm the desired value is in the database… so why isn’t it appearing when I edit the file, and why am I getting the pop-up when I save and try to close it? (Also, the getResources snippet is not ā€œseeingā€ these items in the database, either.)

Is it only a certain TV value/selection where the loading fails?

When you select the same values for the TV in the new resource, that works in an existing resource, does that also fail?

Funny you ask that – I just tested that. I edited an older resource – where this issue does not happen – removed the association in the TV and selected something else from the dropdown, and the problem occurred. If I select the SAME association it had before, it works fine. I also duplicated an old resource and the same thing happened – if it kept its original association, it worked fine; if it changed, it failed.

I should clarify also that this feature – using this TV to make these associations – is something I added AFTER I upgraded the site to 3.1.2. I went back through all the old resources and made these associations, and it worked fine (and this was in September).

I’m not sure I have ā€œsolvedā€ this particular bug, but I have found a successful work-around, and I believe I have a hunch as to the cause of the issue: there’s a comma in the page title. The title is the title of book, so the comma is not trivial or really optional, but it does appear to impact the ability for the TV to secure a relationship to the content in question (because it’s ONLY this particular book that has this issue).

So, I removed the comma in question from the TV dropdown list and from the getResources query, and it works fine. The page still displays the content with the comma, as needed, but for this back-end query I don’t need it.

I am guessing this has something to do with the output specified for the TV – in this case ā€œDelimitedā€ and with a comma as the delimiter. I changed the delimiter to a pipe, but it didn’t seem to matter.

Anyway, problem ā€œsolved.ā€

You could enter the HMTL code &comma; in the page title (and TV dropdown list, if you are setting those values manually). Then, the title would be displayed properly everywhere and wouldn’t trigger the dropdown list issue.

In general, there has been a problem using commas in field labels and TVs. I believe there is a fix in the works somewhere, but I can’t find it in github, and I don’t know if that would fix your problem.

1 Like

Really helpful to know – had not thought of that. Thank you!

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting ā€œ+ New Topicā€.