2008-08-11 01:17:51 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* A special type Int field used for primary keys.
|
|
|
|
*
|
|
|
|
* @todo Allow for custom limiting/filtering of scaffoldFormField dropdown
|
|
|
|
*
|
2009-03-22 23:59:14 +01:00
|
|
|
* @package sapphire
|
|
|
|
* @subpackage model
|
2008-08-11 01:17:51 +02:00
|
|
|
*/
|
|
|
|
class PrimaryKey extends Int {
|
|
|
|
/**
|
|
|
|
* @var DataObject
|
|
|
|
*/
|
|
|
|
protected $object;
|
2008-08-11 01:29:30 +02:00
|
|
|
|
2009-05-06 08:36:16 +02:00
|
|
|
public static $default_search_filter_class = 'ExactMatchMultiFilter';
|
2008-08-11 01:17:51 +02:00
|
|
|
|
2009-03-22 23:59:14 +01:00
|
|
|
/**
|
|
|
|
* @param string $name
|
|
|
|
* @param DataOject $object The object that this is primary key for (should have a relation with $name)
|
|
|
|
*/
|
2008-08-11 01:17:51 +02:00
|
|
|
function __construct($name, $object) {
|
|
|
|
$this->object = $object;
|
|
|
|
parent::__construct($name);
|
|
|
|
}
|
|
|
|
|
2008-10-14 00:20:41 +02:00
|
|
|
public function scaffoldFormField($title = null, $params = null) {
|
2009-01-05 07:19:48 +01:00
|
|
|
$titleField = ($this->object->hasField('Title')) ? "Title" : "Name";
|
|
|
|
$map = new SQLMap($this->object->extendedSQL(), "ID", $titleField);
|
2008-08-11 01:17:51 +02:00
|
|
|
return new DropdownField($this->name, $title, $map, null, null, ' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|