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.

Archive /

Our old forums are still available as a read-only archive.

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

integer field in admin


Go to End


6 Posts   3971 Views

Avatar
superautomatic

Community Member, 53 Posts

28 August 2008 at 8:44pm

Edited: 28/08/2008 8:46pm

Hi, I'm having a strange problem and I can't find anything about in in the ducumentation.

I have made a dataobject for a travel site that holds som extra fields related to a travel page. I want this to have a field 'Price' => 'Int', which works fine. What doesn't work fine thióug, is when I try to add it to the admin interface via getCMSFields_forPopup. I tried the obvious

$fields->push( new IntField( 'Price' ) );

But there is no IntField...

"Fatal error: Class 'IntField' not found in /home/userB/b0015300/public_html/silverstripe/mysite/code/Departure.php on line 18"

So, the short question is: What's the name of the field holding integers?

Avatar
SilverRay

Community Member, 167 Posts

28 August 2008 at 9:40pm

Avatar
superautomatic

Community Member, 53 Posts

28 August 2008 at 9:54pm

No, theres no info about what the Int field is named there. What I'm looking for is the equivalent to "TextField" and "DateField" but for the "Int" datatype. Common sense says it should be "IntField", but it's not.

Avatar
SilverRay

Community Member, 167 Posts

28 August 2008 at 10:02pm

I see what you mean. Can't you just use a NumericField or similar? See:

http://doc.silverstripe.com/doku.php?id=form-field-types

Avatar
Sean

Forum Moderator, 922 Posts

28 August 2008 at 10:05pm

NumericField is what you're after.

Avatar
superautomatic

Community Member, 53 Posts

28 August 2008 at 10:10pm

Yes, NumericField it is. Thaks a lot.