Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » text as a key in CheckboxSetField

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

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

Page: 1
Go to End
Author Topic: 1802 Views
  • blaater
    Avatar
    Community Member
    22 Posts

    text as a key in CheckboxSetField Link to this post

    Hello,

    I'm a newbie to the silverstripe cms, but must say: What a great framework is this!!

    I'm trying to add a checkboxgroup in the cms with some text as the keys, but I only get id's as the value.

    In the documentation is told that you can have text as a key instead of an id in a checkboxgroup:
    http://doc.silverstripe.com/doku.php?id=checkboxsetfield&s=checkboxsetfield

    I've tried it with:
    $fields->addFieldToTab('Root.Content.Main',new CheckboxSetField('Opleiding','Opleiding',array('VMBO','HAVO','VWO','MBO','HBO','WO'),array('VMBO','HAVO','VWO','MBO','HBO','WO')));

    but still there are id's as keys.

    Can somebody help me out?

    Thanks.

  • Sigurd
    Avatar
    Forum Moderator
    628 Posts

    Re: text as a key in CheckboxSetField Link to this post

    You need to pass keys as array keys. This is explained in Tutorial 3 that Andy made

    http://doc.silverstripe.com/doku.php?id=tutorial:3-forms

    Example:

    $browsers = array(
    'FF' => 'Firefox',
    'IE' => 'Internet Explorer',
    'Safari' => 'Safari',
    'Opera' => 'Opera',
    'Lynx' => 'Lynx'
    );
    $browserField = new OptionsetField('Browser', 'Your Favourite Browser', $browsers)

  • blaater
    Avatar
    Community Member
    22 Posts

    Re: text as a key in CheckboxSetField Link to this post

    Thanks for your reply,
    Stupid of me not to try it like this

  • Sigurd
    Avatar
    Forum Moderator
    628 Posts

    Re: text as a key in CheckboxSetField Link to this post

    Sweet. Note the dropdown/optionset/checkbox are basically all the same thing in terms of passing data to them.

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