17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1633 Views |
-
text as a key in CheckboxSetField

10 July 2007 at 4:43am
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=checkboxsetfieldI'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.
-
Re: text as a key in CheckboxSetField

10 July 2007 at 8:18am Last edited: 10 July 2007 8:19am
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) -
Re: text as a key in CheckboxSetField

10 July 2007 at 6:31pm
Thanks for your reply,
Stupid of me not to try it like this
-
Re: text as a key in CheckboxSetField

10 July 2007 at 6:38pm
Sweet. Note the dropdown/optionset/checkbox are basically all the same thing in terms of passing data to them.
| 1633 Views | ||
|
Page:
1
|
Go to Top |


