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 ";