We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3677
    • 130 Posts
    I have a problem where a tv is not rendering properly in my resources. When I look at the rendered HTML, the tv in question is rendered as empty.

    This tv has input options of true||false, with a tv default of empty.

    When I look at the resource in question, the manager UI shows that the tv does have a value of "true", yet it renders as empty.

    When I look in the database directly, I can see that the table "modx_site_tmplvar_contentvalue" does not have an entry associated with the resource in question. If I re-save the resource in question (with the same value "true" that the UI is showing, then I can see that a corresponding entry is instantly created in this db table matching the contentID and tmplvarid with a value of true. After this the tv renders correctly in the HTML.

    So I am wondering, where is the UI retrieving the value reported at the resource level? It can't be directly from the db table above since there is no entry. Also, it is not the default value that it is showing (remember the default for the tv is empty). Is this a caching problem?

    Thanks,
    -Brian
      • 4172
      • 5,888 Posts
      well, this is the behavior of select-boxes.
      If nothing is selected, the first one shows as selected, also if its value is empty.

      This 'preselected' value isn't in the database before you save it, of course.
      After saving, it is.

      If you need an additional empty value add one:

      empty==||true||false
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 3677
        • 130 Posts
        Thanks, adding this empty value lets me see which resources actually have a value for the tv.

        This listbox behavior is really non-intuitive to me though. What you proposed I do with the empty== value is what I had assumed was the default behavior since the tv had a "default value" field set as blank.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          That has nothing to do with MODx, that's just how HTML displays list boxes. You could use a single check box instead.

          What is an "empty" supposed to do? What does "false" and "true" do? NULL (no value at all) is not the same thing as false.

          A true boolean (true-false) condition doesn't have a third option, as the binary nature of true-false is the definition of a boolean. If you're processing this to determine an action or control the output of something, then what you want for your default is "false", and it should be tested in your code as such.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 3749
            • 24,544 Posts
            If you want to force a yes/no choice, you can also use radio buttons, then one of the other will always be set.


            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting