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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

How to show value instead of ID# with CheckboxsetField


Go to End


2 Posts   988 Views

Avatar
woodb2

Community Member, 48 Posts

10 September 2011 at 1:26am

I've been struggling with CheckboxsetField and I thought I had it working (backend works great). When I view the page in the frontend I'm getting ID numbers instead of the values.

I have a Department page that is a $many_many relation to Jobs which is a DataObject

In Jobs my CheckboxsetField looks great, it displays all the Department pages that I've created, but it stores ID# not the titles.

$Rolesob = DataObject::get('Department');

$fields->addFieldToTab('Root.ASIA', new CheckboxsetField('ASIA', 'ASIA (create Department Page first)', $Rolesob));

On my template $ASIA displays 154,156 instead of Accounting, Human Resources

How can I get the values to display?

Any help is appreciated.

Brian

Avatar
UncleCheese

Forum Moderator, 4102 Posts

10 September 2011 at 1:30am

$Rolesob->toDropdownMap('ID','YourLabelField');