Changeset 57242

Show
Ignore:
Timestamp:
02/07/08 13:56:07 (2 months ago)
Author:
ischommer
Message:

BUGFIX Making PrimaryKey? field not rely on the queried objects having at least one result (was triggering $objs->First())

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • modules/sapphire/branches/roa/core/model/fieldtypes/PrimaryKey.php

    r56488 r57242  
    2525                $objs = DataObject::get($this->object->class); 
    2626 
    27                 $first = $objs->First(); 
    28                 $titleField = isset($first->Title) ? "Title" : "Name"; 
     27                $titleField = (singleton($this->object->class)->hasField('Title')) ? "Title" : "Name"; 
    2928 
    3029                $map = ($objs) ? $objs->toDropdownMap("ID", $titleField) : false;