Jump to:

3450 Posts in 1063 Topics by 738 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Comma in Enum() value

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

Page: 1
Go to End
Author Topic: 762 Views
  • Spambanjo
    Avatar
    Community Member
    15 Posts

    Comma in Enum() value Link to this post

    Hi all,

    I have a list of values for my Enum() field which has an option containing a comma. Unfortunately, due to accuracy of information on the site, I do not have the option to re-word this option.

    Can anyone tell me how to escape commas in the Enum() values?

    Thanks in advance.

    EDIT: This is for Silverstripe 2.4.7

  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    Re: Comma in Enum() value Link to this post

    Hi, welcome to the forums,

    I've never tried this, but you should be able to use an array of values instead of a comma separated list. So maybe you can sneak in the comma that way...

  • Spambanjo
    Avatar
    Community Member
    15 Posts

    Re: Comma in Enum() value Link to this post

    Hmmm, I did not know that. I'll give it a shot, thank you!

  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    Re: Comma in Enum() value Link to this post

    @martimiz & @Spambanjo

    would be very interested if this is possible - I asked and Willr said it wasn't a while back...

  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    Re: Comma in Enum() value Link to this post

    I looked at the Enum code in 3.0 - it explodes the list to an array, unless it is already an array. So that should be ok. Don't really know what happens with the array when the field is created. Hence the slight hesitation. Easily testable though...

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: Comma in Enum() value Link to this post

    You can do something like "Enum(array('First Value', 'Second Value'))"

  • Spambanjo
    Avatar
    Community Member
    15 Posts

    Re: Comma in Enum() value Link to this post

    Hi, sorry for my lack of input on this thread, I've been doing a different job and haven't had time to test this yet. I will reply as soon as I have a chance to test this

    I also apologise if this thread is in the wrong place, but this was actually a question for Silverstripe 2.4

  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    Re: Comma in Enum() value Link to this post

    Code for 2.4.7 looks about the same, so that should work as well...

    And sure, this is the right place, there are no separate forums for 3.0 or 2.4. This can be confusing, because of the major differences in both versions, so people: please mention your version. (just taking the opportunity to mention this )

    762 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.