Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Knittl 13 posts 114 karma points
    Mar 21, 2019 @ 09:58
    David Knittl
    0

    Negative values for decimal show validation error

    Hi everyone,

    I have a small Umbraco site running on version 7.13.1 und am playing around a bit in version 8. The goal is to set up everything in v8 and continue development there.

    Unfortunately, I'm having a bit of a problem with the decimal data type. I use it to store some values in our site and those values can also be negative. Everything worked flawlessly in v7, but in the v8 site I can't save and publish any content items with negative values in the decimal property. It always gives a validation error: "Property has errors"

    If I manipulate the content in code (get an IContent through the ContentService, use the SetValue method on that object and then the SaveAndPublish method to save) I can input negative values in those properties and they then show up properly in the backend when viewing those content items. But I can't save them until I remove the minus in the textbox. I guess something in the validation is broken.

    Anyone else run into this problem? And do you have any idea how to fix it?

    Cheers, David

  • David Knittl 13 posts 114 karma points
    Mar 22, 2019 @ 09:05
    David Knittl
    100

    I think I found a fix:

    In ~/Umbraco/Views/propertyeditors/decimal/decimal.html you need to change the pattern attribute of the input field to

    [-]?[0-9]+([,\.][0-9]+)?
    

    That did the trick for me. Now decimal fields accept negative values.

Please Sign in or register to post replies

Write your reply to:

Draft