Maybe someone else can replicate the following behaviour and confirm whether a) it's what you would expect and b) is there are way round it?
I have two templates, "Article" and "Event". For the "Article" template I have assigned a radio TV called "Colours" with options red, green and blue. The default is set to "green". The TV is NOT assigned to "Event".
I make a document with the Event template, and in its content I try to access the TV with
. As the Colours TV is NOT assigned to this template I would expect to get nothing/null back, but instead I get "green" (the default value).
It happens programmatically too (using getTVValue("Colours")).
I know an obvious answer is to simply not access that TV from a template that doesn't have it assigned, but in my particular case I was using it as part of a snippet that is used in both templates I was trying to do something like the following, where my "Selection" array is composed of resources that could be using either the Articles or Events template:
foreach($Selection as $Resource) {
$Colour = $Resource->getTVValue("Colours");
// Here, if the Resource does not have the Colours TV assigned,
// I would expect Colour to be null or empty, not the TVs default value.
$action = $Colour==='green' ? 'this' : 'that';
//etc
}
Does that make sense?! Do I need to check for a TV's "existence" instead and if so what's the quickest way of doing that?
Thanks