cosmocode / dokuwiki-plugin-struct

A new structured data plugin
https://www.dokuwiki.org/plugin:struct
GNU General Public License v2.0
40 stars 40 forks source link

Implement a way to force leading zeroes for numbers #714

Open asheenlevrai opened 5 months ago

asheenlevrai commented 5 months ago

Feature Description

Hi :)

My "problem" is described in this thread on DW user forum.

Basically, we need a way to force leading zeroes for numbers (similar to how the Data plugin would support this).

Our users use a Bureaucracy form where they need to input a number in one of the fields. They can enter whatever number from 0 to 999999. However, we need the number to be a 6-digit number. So for now we solved this by using the parameter "000000" in the Bureaucracy form, for the Number field. User input is automatically converted into a 6-digit number by adding leading zeroes.

However, when switching from Data to Struct. This no longer works. The "000000" parameter in the form has no effect.

We used the type "decimal" for the number in the Struct schema (since there isn't a "number" type) [[EDIT: and tweaked it to accept 0 decimals (roundto=0) 20240508: Actually I realized that's not what roundto does. Roundto rounds the value entered by the user to what the parameter defines and displays that in the aggregation table. Here if the user enters 11.6, the number displayed in the table would be 12. but the value for "number" would still be 11.6 /EDIT]].

Any chance to implement this feature? Otherwise could you give me some advice about how to achieve this differently?

Thank you very much :) -a-

gregoryloichot commented 4 months ago

That would be solved with #715 right ?