Hi folks,
I've been working on a project that involves custom handling for dropdown menus that have only one option, and I think I've found another Miva Script bug related to objects, or maybe arrays. (I say "another" because I recall some odd behavior where a variable's value gets destroyed in some cases when you reference it in the VALUE part of an MvASSIGN.)
I was using this conditional to find out whether the attribute had only one option:
I was getting weird results, and after much head-scratching and putting in debugging messages, I found that executing this statement was causing a second element to be created in the attribute:options array. I changed the conditional to this:
and it worked correctly: an attribute with only one option would continue to have only one option.
Admittedly, the first conditional was not the most elegant way to test for the existence of a second array element. But still, I can't see any reason why it should actually modify the value of the attribute:options array. I understand that the len(x) function involves converting the value of x to a string. But that conversion should be done within the len() function; it shouldn't actually change the value of x. Or am I missing something?
Thanks --
I've been working on a project that involves custom handling for dropdown menus that have only one option, and I think I've found another Miva Script bug related to objects, or maybe arrays. (I say "another" because I recall some odd behavior where a variable's value gets destroyed in some cases when you reference it in the VALUE part of an MvASSIGN.)
I was using this conditional to find out whether the attribute had only one option:
Code:
<!mvt:if expr="(NOT len(l.settings:attribute:options[2]:code))">
Code:
<mvt:if expr="miva_array_elements(l.settings:attribute:options) EQ 1">
Admittedly, the first conditional was not the most elegant way to test for the existence of a second array element. But still, I can't see any reason why it should actually modify the value of the attribute:options array. I understand that the len(x) function involves converting the value of x to a string. But that conversion should be done within the len() function; it shouldn't actually change the value of x. Or am I missing something?
Thanks --
Comment