We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26876
    • 12 Posts
    Hello,

    I’m not sure if this is considered a bug or intended behavior but I’m reporting it anyway. Several topics already touch on TV’s and their saving behavior, but I did not see a direct connection with the issue I’m describing.

    When you create a new document that has a TV attached that has a default value, this default value is shown as you would expect. As example, we have a TV of type text, called "letter" with a default value of "A". Changing this value to "B" in the new document and save, it’s correctly saved and shows "B". Now, I do not want any value there, so I change it to "" (empty string). Save the document, and hey, the value reads "A".

    In my opinion, the default value should only be inserted into the field when a new document is created. An empty string is now always considered to be invalid.

    An exception would be if you could indicate that the field cannot be empty (maybe some checkbox). Taking the default value would then be a good option.

    For reference, the default value logic is (partially) done by:
    $sql = "SELECT DISTINCT tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value ";
      • 22303 MODX Staff
      • 10,725 Posts
      Let’s just call it a buggy feature, or is that a featured bug? tongue

      But seriously, I concur with you that setting a blank value should not be the MO for resetting a TV to it’s default value as it currently is. This should be a separate button/action available on the TV, so that you can set the value to empty. I’ll get a feature request in for this.
        • 26876
        • 12 Posts
        Cool, thanks smiley