• Resolved adrianwelsh

    (@adrianwelsh)


    Is there a way to increase the decimal field type precision and scale? I see that it’s 14,4 (I think) but I would like to increase it to a precision of 8 (8 digits past the decimal point). I have a feeling that after I change this in the backend database that it will get reset when the plugin updates.

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author xnau webdesign

    (@xnau)

    You can change it in the database, updates won’t touch it, however, if you edit the field, it will revert to the 14,4 setting…and you can lose data when that happens.

    The way around this is to set up a filter that redefines the decimal datatype. I’ve written this up as a plugin you can download here: https://gist.github.com/xnau/3c191ec34923ff10c832aaf285a2b68b

    Thread Starter adrianwelsh

    (@adrianwelsh)

    Thanks, that makes sense. But, I’m not sure how to implement this plugin. Do I insert it into one of my folders? Or somehow make it a new plugin?

    Plugin Author xnau webdesign

    (@xnau)

    Easiest way is to download the .zip file, then in your WP admin, go to Plugins/Add New. This gives you a way to upload the zip file and install the plugin.

    You will have to edit it to match your particulars, that plugin is just an example. You can edit it once you install it and before you activate it, the plugin menu has an editor.

    Thread Starter adrianwelsh

    (@adrianwelsh)

    Thanks for the instructions. I downloaded the zip and then I uploaded it into my plugin. I can see it (it is activated) but I do not think it is working with 8 digits past the decimal (as indicated in the code).

    I don’t think I set it up properly to my particulars as I’m not sure how to do that. What step did I miss? How do I match this plugin to my Participants Database plugin data types?

    Plugin Author xnau webdesign

    (@xnau)

    What this plugin does is set the datatype parameter for the decimal form element type. That change won’t take place in the database until the field is saved.

    The only thing you’d need to change is the number of decimal places you want to use.

    Thread Starter adrianwelsh

    (@adrianwelsh)

    In order to save the decimal field again, should I save the field type as something different and then back to a decimal? Or is there another way to save my field type so that the change will take place?

    Plugin Author xnau webdesign

    (@xnau)

    When the field definitions are saved, only those that have been changed are actually updated, so any change you make (even if you just change it right back before saving) is enough to cause the field definition to be saved when “update fields” is clicked.

    Thread Starter adrianwelsh

    (@adrianwelsh)

    Well, that was easy! I just made a simple change, like you mentioned, saved it, and voila! It worked! Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Adding more precision to decimal values’ is closed to new replies.