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.

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   599 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;
}