0

I've got an Event content type that has coupled events. The content type does not have a title. I've defined a searchable_fields private static:

private static $searchable_fields = array(
    'ProjectNumber',
    'EventDate'             => 'PartialMatch',
    'TicketCode'            => 'PartialMatch',
    "Package.Title"         => 'PartialMatch',
);

Searching in the field (see attachment) is working, but I only see the ID, whcih is, to say the least, less than optimal :-). Does anyone know how to override the system in such a way that it shows the TicketCode or EventDate?

Dropdown example

2 Answers 2

1

By default, the GridFieldAddExistingAutocompleter displays the $Title of the result. If you don't have Title or Name field, this defaults to #$ID, as you're seeing.

You can either add a getTitle method to your class that returns what you want, or change what gets returned by the component.

You'd do this using something like:

$config->getComponentByType('GridFieldAddExistingAutocompleter')->setResultsFormat('$TicketCode - $EventDate.Nice');
1
  • Thanks! In the end I used the getTitle method.
    – jberculo
    May 1, 2014 at 8:39
0

Define the fields you'd like to display in the GridField using:

private static $summary_fields = array(
    'TicketCode',
    'EventDate'
);

Documentation here: http://doc.silverstripe.org/framework/en/reference/dataobject#summary-fields

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.