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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

Changing value in a column of DataGrid

Go to End

11 Posts   2084 Views

George Botley

Community Member, 18 Posts

16 October 2013 at 1:07pm

Thanks zenmonkey, I will look at your code and see the changes you made to see if I can finally get my head around this..

As for your recommendation, that is what I am already doing am I not.. in the sense that the category ID is stored in the Article.

My reasoning for doing this is that should someone want to change the category name at a later date then they could.

Sorry to be a pain.. Is there a change I need to make here to.


Community Member, 545 Posts

16 October 2013 at 1:25pm

You are setting a relation the way you're doing it but manually. If you want to get the Category Title you need to write your own database call, but if you set the relation via a $has_one $has_many, SilverStripe will do all the relation getting and joins for you. If you want to keep it the way you have it now, you can get the Category Title by creating a custom getter.

function getCategoryTitle() {
  $catergory = ArticleCatagory::get()->byID($this->Category);
  return $category->Title;

Then you'll be able to show it a gridfield by using CategoryTitle instead of Title

George Botley

Community Member, 18 Posts

16 October 2013 at 1:39pm


I understand it now. It now links together, and what's funny with SilverStripe is you always try to make something work in a more complex way, when really.. under the hood is a simple solution to most problems.

Thanks zenmonkey, your the man. Don't suppose you could check out my other post on getCMSValidator within DataObject?


Go to Top