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.

Data Model Questions /

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

GridField 'Link Existing' dropdown showing record ID not Title


Go to End


4 Posts   3176 Views

Avatar
_Matt

Community Member, 29 Posts

23 August 2014 at 2:19am

I'm creating a simple blog with categories using the DataObjectAsPage Module.

I have a DataObject called BlogCategories that has a belongs_many_many relationship with the BlogPost DataObject.

Everything works fine, apart from when you are editing a BlogPost and adding categories - the 'Link Existing' dropdown shows Category IDs rather than titles.

I'll try and add a screengrab below so you see what I mean...

I'm not manually adding the GridField (as per this tutorial), this is simply how SilverStripe is doing it by default. I have also tried adding the GridField manually, but that does the same thing.

Can anyone point me in the right direction?

Avatar
Rob Clarkson

Community Member, 26 Posts

17 September 2014 at 12:37pm

Edited: 18/09/2014 9:25am

Not 100% sure, but think this might be cos SS automatically looks for "Title" to map the names in the dropdowns.

What field name did you give your "Category Names"? try changing it to "Title" cased like this.

Cheers
Rob Clarkson

Avatar
Abdou

Community Member, 3 Posts

15 October 2014 at 5:42pm

_Matt: you are right or change it to name and it will work perfect

Avatar
aktorou

Community Member, 2 Posts

28 January 2016 at 5:24am

Edited: 28/01/2016 5:25am

Just a heads up. If you don't want to change the db field name to Title, just create a function that links the relative db fields to it.

public function getTitle(){
    return $this->FirstName . ' ' . $this->LastName;
}

Tested in SS 3.2.1

Hope that helps
- Ash