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.

Archive /

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

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

Automatic filling database fields with values


Go to End


2 Posts   2335 Views

Avatar
Jarek

Community Member, 30 Posts

29 November 2008 at 1:43am

The way to edit additional db table fields in CMS is to overwrite getCMSFields function. I want to fill some fields automaticly and disable them from editing by cms users. How can I make this? I see to solutions:

1) worse - in getCMSFields fill fields witah values, and disable them from editing in cms
2) better - catch save action called when button "save & publish" pressed and set fields

First solutions is quite easy to implement. But I've no idea how make second solution.

Thx for any help

Avatar
Nivanka

Community Member, 400 Posts

29 November 2008 at 8:57am

this is not hard at all, try with overriding the $defaults array,

and specify the default values you need there.

then after that in the getCMSFileds method use headerfields