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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

NumericField() and negative numbers


Go to End


3 Posts   1849 Views

Avatar
DeklinKelly

Community Member, 197 Posts

9 September 2009 at 11:52pm

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

Community Member, 85 Posts

20 February 2010 at 1:13pm

Edited: 20/02/2010 1:19pm

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

Community Member, 54 Posts

24 February 2010 at 7:52pm

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