Can't edit existing TVs

I can add content to image TVs and plain text TVs but I can’t delete or edit the TV content. The changes are not saved in the resource.
Modx 2.7.2, PHP 7.3. I’ve reset all permissions and compress js / compress css is turned off. Mod security is not installed.
Was just about to upgrade this site when I noticed the problem. Didn’t want to upgrade it without solving the problem first. Any ideas?

Is there anything in either your PHP error log, or the MODX error log?

The only error I’m getting is as follows but this does not seem to be triggered at the same time as saving a resource…

[2022-10-31 16:24:19] (ERROR @ /var/www/vhosts/ : 177) Error outputting thumbnail:
OutputThumbnail() failed because !is_resource($this->gdimg_output) in file "phpthumb.class.php" on line 640

If you edit the content of the TV and hit Save, do you see the Success! Save Successful message?

Also if you open DevTools Network tab, then try to save the resource after making changes to the TV - do you see any errors in there?

Success! Shows. No errors in console / network. Tinymce wrapper is installed on this site so I may well disable that and try again.

1 Like

Disabling TinymceWrapper made no difference. The only thing I’m seeing in Chrome is:

Event.path is deprecated and will be removed. Please use Event.composedPath() instead.
1 source

Do the standard fields like pagetitle & content edit and save ok?

Yes - it’s just the custom TVs that are problematic

What custom TVs are these, or did you make them yourself?

Internally, TVs write to a hidden input named tv123 where 123 is the ID of the TV. It sounds like the custom TVs might not be saving its values correctly?

To confirm that’s the problem, try inspecting the ajax request when saving the resource. If it works correctly, you should find the tv123 (with your TV’s ID) with updated values there. If you don’t see that, then the problem is with the TVs.

They are pretty standard TVs that I’ve created. An image tv, rich text area, listbox and text. The listbox will save.
I couldn’t see anything in the ajax requests with exactly tv## but I just tried to duplicate one of the TVs in question and Modx manager threw an error: ‘Template Variable not specified’ when I try to access the duplicated TV.

So by “custom” you mean the standard core-provided image/rich text/listbox/text TVs you set up? Or actual custom TVs you developed with custom input classes and such?

That error when duplicating it makes me wonder if somehow the TV input type isn’t set correctly?

Sorry yes - they are standard TVs. Just added a new TV and it seems like there is no id applied to it i.e. the name of the TV in the Elements tree is: testonly (0)

Is the ID in the database table (modx_site_tmplvars) correct?

Will check tomorrow - thank you for the input everybody

The ids of the TVs in modx_site_tmplvars match those shown in Modx. There are 47 TVs in all (no.4 is skipped so presumed deleted at some point). There are so many because TinymceWrapper creates a load. The TV I created yesterday has an id of 0 as does the duplicate that I created yesterday. Is it significant that the source column is set at 0 for some TVs and 1 for others? There is only one media source - Filesystem. There’s not a maximum number of TVs allowable is there?

The id column of the table modx_site_tmplvars should be an AUTO_INCREMENT column with an index to assure unique values.

So neither a value of 0 nor two equal values should ever exist.

Maybe check the table structure (for example with phpMyAdmin).

Auto_Increment isn’t ticked so I’m guessing that’s the place to start. In fact, even if I create a chunk, it’s getting an id of 0. Maybe best to re-install Modx?

As the id column or its auto increment flag isn’t a new addition, the setup isn’t programmed to add it to an existing site, so I don’t think anything but a completely fresh install will add those again. You can add it via phpmyadmin but if it’s also missing for chunks, something seems to have gone pretty wrong.

A clean install that you import a database backup with only data to (not table structure) might be easiest to make sure it’s all correct.

Curious, though, that it did work before - did something happen to the database since the last successfully added chunk/tv?

This is quite an old website that’s been upgraded over the years and then around a year ago it was moved to a different server. No updates (that affected editing TVs) were since done until last week, when I noticed the problem. I’m guessing it was the server move that caused the problem.
How do I do a clean install in that way - any instructions anywhere?