We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36491
    • 36 Posts
    I noticed that when a number TV has the value 0 and is edited in NewsPublisher, the input field is left empty. So after saving, the TV is now empty. Is this expected behaviour? I'd expect "no value" would be different from 0, just like in the modx manager.

    (In my use case we ask for a recommended minimum age for an event. If the editor says 0, then it's for all ages, if she gives no information, we assume it's for adults only.)

    How can this be fixed?
      • 3749
      • 24,544 Posts
      I can't see any easy way to fix this in the code, but if I have time, I'll take another look.

      It might possibly work to alter the NewsPublisher npIntTpl chunk. Back it up first, then try changing this part:

      value="[[+np.[[+npx.fieldName]]]]"


      to this:

      value="[[+np.[[+npx.fieldName]]:empty=`0`]]"
        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
        • 36491
        • 36 Posts
        Thanks for the quick reply!

        Quote from: BobRay at Feb 05, 2019, 06:08 PM

        value="[[+np.[[+npx.fieldName]]:empty=`0`]]"

        Unfortunatly this does not help as it just sets every empty int-field to 0, which would screw up a lot of other fields that users can intentionally leave empty.

        I guess for now I temporarily change the docs so that the users have to insert 1 instead of 0 as a starting age for everyone, hoping that the infants don't read it …
          • 3749
          • 24,544 Posts
          You could use JavaScript to change the display of that specific field if it's empty. I think the ID would be np.tvName. You could find out by examining it in Chrome or Firefox dev. tools.

          In JQuery, it would be something like this:

          var value = $('#np.tvName').val();
          if (empty(value)) {
              $('#np.tvName').val('0');
          }
            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