Jump to:

23371 Posts in 18161 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » Really Long Names in Enum

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

Page: 1
Go to End
Author Topic: 1003 Views
  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Really Long Names in Enum Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Really Long Names in Enum Link to this post

    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.

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Really Long Names in Enum Link to this post

    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')",
       );

    1003 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.