Some template variables successfully save, but if I return to the Resource afterwards to make additional changes, they now appear empty. Saving with these empty fields then removes any set values.
Step to reproduce
Open Resource using Template Variables
Set template variable
Observe it is correctly set in the page
Navigate away
Return to resource
Observe variables are now empty
Saving now clears template variables
Observed behaviour
Template variables are now empty
Expected behaviour
Template variable should retain its previous settings
Does this happen with all the template variables or just the ones with a certain âInput Typeâ?
Does the same happen with normal resource fields (like pagetitle, etc.) or only with TVs?
Just to make sure I understand the issue correctly:
You can still set the TV values and these values get stored in the database (table modx_site_tmplvar_contentvalues) and are visible on the front-end (with tags like [[*tv_name]]).
But when you reload the resource in the manager, the input fields for the TVs are empty?
It happens with some template variables which use the same types as others, but some have this issue.
And yep, the template variables appear to work fine until a reload when they are then emptied - if the user then makes a change and saves the data is lost.
Hasnât appeared to affect built in variables yet as far as I can tell.
Is it possible to provide more specific information?
What TV input types are affected?
Does the issue only occur with certain values? Maybe values that contain unusual characters (e.g. umlauts, cyrillic)?
Also, are there any plugins on your system that run on the events OnResourceTVFormPrerender or OnResourceTVFormRender?
Under â âSystem Settingsâ â tab âSystem Eventsâ you can see what plugins run on what event. Use the âSearchâ field to filter by the event name and then check the column âPluginsâ.
Values are all standard Latin characters with no or minimal punctuation. I have used HTML in other TVâs but those TVâs have not had problems saving.
OnResourceTVFormPrerender doesnât have an entry in System Events for me, and OnResourceTVFormRender has no plugins that run on that event.
In terms of packages, Iâm running:
Ace
AjaxForm
BigBrother
CacheClear
CSRF Helper
FormIt
Guzzle7
QuickEmail
VersionX
Apologies for the issue, it could be simply a first time user problem!
MODX 3.1.2-pl has been released almost 2 months ago now, and if there was a general issue with loading the TV values, this would be immediately obvious on almost every MODX installation. But I havenât seen this issue before, here in the forum or on Github, and I canât reproduce it myself.
There must be something unique occurring on your system, but I have no idea what.
Does the same issue happen if you use another browser? Maybe a browser plugin is interfering?
When you open the âNetworkâ tab in the developer tools of the browser and then reload the MODX resource (manager/?a=resource/update&id=...), can you find the information for the TVs in the response?
There should be an HTML <input> tag for every TV in the response with the ID and name equal to tv + ID of the template variable. For example a TV of âinput typeâ= text with the ID = 3 would look like this:
<input id="tv3" name="tv3"
type="text" class="textfield"
value="my tv value"
tvtype="text"
/>
Is the value attribute already empty in the response?
The problem doesnât seem to be the saving of the TV values, but rather loading them.
So if a plugin is interfering, then itâs more likely an event like OnDocFormRender or OnDocFormPrerender (besides OnResourceTVFormPrerender and OnResourceTVFormRender I mentioned before).
But none of the listed extras that are installed seem to be âsuspiciousâ.
No itâs not empty! This is a <select> (probably from a TV of input type âListbox (Multi-Select)â) and the Option Programming is selected (selected="selected").
Iâm also a bit confused why all the option values contain a comma at the end ( â "Programming,", "2D Art,", etc.). What are your settings for this TV (especially âDropdown List Optionsâ)?
The reason they have a comma is because I used them to generate a CSV for a snippet for categorisation - which it turns out was the issue! Removing them fixed the problem.
Just in case anyone runs into this in the future, the proper way of generating a CSV is via the Output Options to set a delimiter.
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â.