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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Changing datatype IDs to titles in ModelAdmin


Reply


2 Posts   288 Views

Avatar
lozhowlett

Community Member, 146 Posts

18 July 2013 at 3:52am

Guys

Please see attached, I have a model VehicleType

<?php
class VehicleType extends DataObject
{
static $db = array (
'VehicleTypeName' => 'Varchar(255)',
'VehicleRegRequired' => 'Boolean'
);

static $has_one = array(
);

static $has_many = array(
'Tariffs' => 'Tariff'
);

static $searchable_fields = array(
'VehicleTypeName',
'VehicleRegRequired'
);

static $summary_fields = array(
'VehicleTypeName',
'VehicleRegRequired'
);

}

When I create a new Vehicle type in admin it says "Saved #1". I want to to say "Saved "Car"" instead. Is this possible?

Thanks

Attached Files
Avatar
kinglozzer

Community Member, 171 Posts

18 July 2013 at 4:05am

Edited: 18/07/2013 4:05am

You should be able to do it like this:

public function getTitle() {
   return $this->VehicleTypeName;
}