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:

General Questions /

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

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

Changing datatype IDs to titles in ModelAdmin


Go to End


2 Posts   501 Views

Avatar
lozhowlett

Community Member, 151 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, 187 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;
}