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

Really Long Names in Enum


Go to End


3 Posts   1369 Views

Avatar
swaiba

Forum Moderator, 1899 Posts

14 May 2011 at 2:45am

This might be a dumb question but...

I've got an enum with really long names in it...

'Type'=>"Enum('ReallyReallyReallyLongNameA,ReallyReallyReallyLongNameB,ReallyReallyReallyLongNameC,ReallyReallyReallyLongNameD,ReallyReallyReallyLongNameE,ReallyReallyReallyLongNameF,ReallyReallyReallyLongNameG','ReallyReallyReallyLongNameG')",

...it's getting far too long and really annoying, is there another way to specify these or should I start make ABR (abreviations) for them?

Avatar
Willr

Forum Moderator, 5523 Posts

14 May 2011 at 1:07pm

I would recommend using abbreviations and have a map somewhere in your PHP which maps the abbreviated version to the full version if you need. That or just don't use enums (just use strings) and store the list of strings elsewhere.

Avatar
swaiba

Forum Moderator, 1899 Posts

12 January 2013 at 4:59am

Edited: 12/01/2013 5:25am

Found an answer to this... if you switch it to be an array then it can parse line breaks as each item is quoted - happy days!

Example...

	 static $db = array(
		'Name' => 'Varchar(255)',
		'Type' => "Enum(
			'array(
				'General',
				'Cancel'
			),
			,'General')",
	);