silverstripe-framework/forms/TypeDropdown.php
Sean Harvey 8e1f647252 MINOR Added to @deprecated note for TypeDropdown about why this class shouldn't be used
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64505 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-10-19 00:41:16 +00:00

40 lines
1.1 KiB
PHP
Executable File

<?php
/**
* Create a dropdown from all instances of a class.
*
* @package forms
* @subpackage fields-relational
*
* @deprecated 2.3 Misleading naming, and having an entire class dedicated
* to just setting the source mapping for a DropdownField is overkill. Just
* use a standard DropdownField instead.
*/
class TypeDropdown extends DropdownField {
/**
* @var string $titleFieldName The name of the DataObject property used for the dropdown options
*/
protected $titleFieldName = "Title";
/**
* @param string $name
* @param string $title
* @param string $className
*/
function __construct( $name, $title, $className, $value = null, $form = null, $emptyString = null) {
$options = DataObject::get($className);
$optionArray = array( '0' => _t('TypeDropdown.NONE', 'None') );
if($options) foreach( $options as $option ) {
$optionArray[$option->ID] = $option->{$this->titleFieldName};
}
parent::__construct( $name, $title, $optionArray, $value, $form, $emptyString );
}
function setTitleFieldName($name) {
$this->titleFieldName = $name;
}
}
?>