Currently, if I want a user to enter a number, I use the following code:
[[form]]
field:
number:
label: Enter a number:
type: text
match: /^\d+(\.\d+)?$/
match-error: Please enter a number.
[[/form]]
This validates numbers perfectly.
Problem
Sorting pages via data field type will sort everything in alphabetical order. Including numbers.
For example, 100 will be sorted before 99.
If there were a "Number" field, apart from having the field automatically validated by Wikidot, we would be able to sort our Data Form fields numerically.
It is already possible to sort numerically using the select fieldtype in your dataform, .e.g.
Then use order="_albums desc" in your listpages module.That gives the result you see at http://vineyard.wikidot.com/bands:main where the number of albums is sortred in descending order.
BUT….and it's a big but….you need to know what your maximum number will be in the select field on the dataform and add every number in to the values. I wouldn't like to do that if I needed numbers in the hundreds or thousands.
With a number field type (which, with dates, is an obvious gap in the current dataform fieldtypes) the need to pre-specify numbers is removed and it is a lot more logical.
So I strongly support James' wish and give it a +1
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Thanks for the plus one!
But in your example, I do believe placing a zero before a number switches to the Octal numbering system, where numbers such as 8 and 9 do not exist, and are assumed to be zero instead. I think your example only works properly when you surround each number with quotation marks:
Reference: http://feedback.wikidot.com/bug:436/comments/show#post-1204246
λ James Kanjo
Blog | Wikidot Expert | λ and Proud
Web Developer | HTML | CSS | JavaScript
Yes I had copied the wrong (earlier) select fields (now corrected) into my post above. Providing there is no space before the number the ordering works well. I have just added Gerry Rafferty in to my list with 9 albums and it sorts properly. And that was also what I wrote in the documentation.
But of course that doesn't remove the need for a proper number field type.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
If your numbers aren't consecutive, have a large range, and many may never be used, a select field is an weak solution compared to a number field.
For example, let's say I have a category of sports players and I want to sort them by annual income. This could range from $0 (amateur/college athletes) to $50,000,000 US (professional).
A number category is a great idea.
I have at least one use case for true numeric fields where using an enumerated set of options is impractical. At least one of these cases needs aggregation on these fields, which isn't supported at all with the current data forms.
Jay Bienvenu | Hilinqwo: A constructed language