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

Is it possible to edit the ID field through the CMS?


Go to End


2 Posts   1866 Views

Avatar
BigD1214

Community Member, 24 Posts

11 August 2012 at 6:03am

I am looking to add the ability to show and edit the ID field of one of my database through the data manager in the cms. Can anyone please help me out? Thanks in advanced.

Avatar
ajshort

Community Member, 244 Posts

13 August 2012 at 3:15pm

Edited: 13/08/2012 3:18pm

You can show the ID field like any other:

$sfield->addFieldToTab('Root.Main', new ReadonlyField('ID', 'Record ID'));

However, you can't make it editable - the ID is expected to be immutable, and is automatically generated. I can't think if a reason why you would want to make the ID editable - perhaps if you say why you need to do this an alternative solution can be found.

Note: for some databases it would be technically possible to allow editing the ID in the CMS, but this would be a very bad idea.