[pmwiki-users] Wikiform - empty fields, numeric type, page names

Patrick R. Michaud pmichaud at pobox.com
Tue Dec 13 15:37:30 CST 2005


On Wed, Dec 14, 2005 at 10:28:47AM +1300, John Rankin wrote:
> On Tuesday, 13 December 2005 11:27 PM, Andreas Mühlhausen <mail at andreas-muehlhausen.de> wrote:
> >Hi John,
> >
> >>>2) Is it possible to define a numeric field type, because I want to use 
> >>>a numeric ordering in the (:wikilist:)?
> >>
> >>This can be added. To make the sort work, the form administrator will need 
> >>to specify a length and the data will be automatically zero filled.
> >>  
> >>
> >I think a solution with zerofilled values is not so good, because I have 
> >values like i.e. 300 kilometres and it doesn't look quiet good if the 
> >list displays them as '0300 km'. This is why I asked for
> >numeric values.

I'm coming at this late in the discussion (and don't know all of the
details), but a different approach might be for the form administrator 
to specify which fields are numeric, and use numeric comparisons 
for sorting those fields instead of zero padding and using string 
comparisons.  This also solves problems with negative versus positive values.

In PHP, a value can be converted from string to numeric by simply
adding zero:

    $a = "123"      # $a is a string '123'
    $a += 0;        # $a is now a numeric 123

So, if there's just some mechanism to specify that a given field
is numeric (or to be compared numerically), that could be simpler.

Pm




More information about the pmwiki-users mailing list