Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

NumericField() and negative numbers


Reply

3 Posts   1337 Views

Avatar
DeklinKelly

9 September 2009 at 11:52pm Community Member, 197 Posts

NumericField() does not support negative numbers. If I supply "-100" it returns:

'-555' is not a number, only numbers can be accepted for this field

Is this a bug or am I missing something?

Avatar
Samba Sam

20 February 2010 at 1:13pm (Last edited: 20 February 2010 1:19pm), Community Member, 85 Posts

I get the same error in my custom CMS tab when I try to enter a negative number into the Int field.

For example,
With this
public static $db = array(
      'TopMargin' => 'Int',
   );

and this
...
new NumericField("TopMargin", "Top Margin"),
...

I get "'-20' is not a number, only numbers can be accepted for this field".
As a result, I am having to use TextField instead.

Perhaps I am missing somethings as well? Negative integers are numbers.

Anyone have any ideas?

Thanks,
Sam

Avatar
mobius

24 February 2010 at 7:52pm Community Member, 54 Posts

Looks like a bug. I've opened a ticket and posted a patch here: http://open.silverstripe.org/ticket/5116