<![CDATA[ newspublisher: Treatment of value 0 in number TV - My Forums]]> https://forums.modx.com/thread/?thread=104883 <![CDATA[newspublisher: Treatment of value 0 in number TV]]> https://forums.modx.com/thread/104883/newspublisher-treatment-of-value-0-in-number-tv#dis-post-563959
(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?]]>
frischnetz Feb 05, 2019, 12:34 AM https://forums.modx.com/thread/104883/newspublisher-treatment-of-value-0-in-number-tv#dis-post-563959
<![CDATA[Re: newspublisher: Treatment of value 0 in number TV]]> https://forums.modx.com/thread/104883/newspublisher-treatment-of-value-0-in-number-tv#dis-post-563985 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');
}
]]>
BobRay Feb 06, 2019, 03:05 AM https://forums.modx.com/thread/104883/newspublisher-treatment-of-value-0-in-number-tv#dis-post-563985
<![CDATA[Re: newspublisher: Treatment of value 0 in number TV]]> https://forums.modx.com/thread/104883/newspublisher-treatment-of-value-0-in-number-tv#dis-post-563984
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 …]]>
frischnetz Feb 06, 2019, 02:28 AM https://forums.modx.com/thread/104883/newspublisher-treatment-of-value-0-in-number-tv#dis-post-563984
<![CDATA[Re: newspublisher: Treatment of value 0 in number TV]]> https://forums.modx.com/thread/104883/newspublisher-treatment-of-value-0-in-number-tv#dis-post-563970
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`]]"
]]>
BobRay Feb 05, 2019, 06:08 PM https://forums.modx.com/thread/104883/newspublisher-treatment-of-value-0-in-number-tv#dis-post-563970