Classes:

fields-formattedinput
AjaxUniqueTextField
AutocompleteTextField
ConfirmedPasswordField
CreditCardField
CurrencyField
CurrencyField_Disabled
CurrencyField_Readonly
EmailField
HtmlEditorConfig
HtmlEditorField
HtmlEditorField_Readonly
HtmlEditorField_Toolbar
NumericField
PasswordField
PhoneNumberField
UniqueRestrictedTextField
UniqueTextField
fields-basic
CheckboxField
CheckboxField_Disabled
CheckboxField_Readonly
CheckboxSetField
DropdownField
GroupedDropdownField
ListboxField
LookupField
NullableField
OptionsetField
ReadonlyField
TextareaField
TextField
fields-relational
ComplexTableField
ComplexTableField_Item
ComplexTableField_ItemRequest
ComplexTableField_Popup
CountryDropdownField
HasManyComplexTableField
HasManyComplexTableField_Item
HasOneComplexTableField
HasOneComplexTableField_Item
LanguageDropdownField
ManyManyComplexTableField
ManyManyComplexTableField_Item
ScaffoldingComplexTableField_Popup
TableField
TableField_Item
TableListField
TableListField_Item
TableListField_ItemRequest
TreeDropdownField
TreeDropdownField_Readonly
TreeMultiselectField
TreeMultiselectField_Readonly
TreeSelectorField
fields-structural
CompositeField
FieldGroup
FieldSet
HiddenFieldSet
SelectionGroup
Tab
TabSet
ToggleCompositeField
validators
CustomRequiredFields
RequiredFields
Validator
fields-dataless
DatalessField
HeaderField
HiddenField
LabelField
LiteralField
ToggleField
fields-datetime
DateField
DateField_Disabled
DatetimeField_Readonly
TimeField
TimeField_Readonly
transformations
DisabledTransformation
FormTransformation
PrintableTransformation
PrintableTransformation_TabSet
ReadonlyTransformation
TabularStyle
fields-files
FileField
FileIFrameField
ImageField
SimpleImageField
SimpleImageField_Disabled
core
Form
FormField
FormResponse
Form_FieldMap
actions
FormAction
FormAction_WithoutLabel
ImageFormAction
InlineFormAction
InlineFormAction_ReadOnly
ResetFormAction
fields-formatted
RestrictedTextField

Files:

Show/hide

subpackage actions
FormAction.php
ImageFormAction.php
InlineFormAction.php
ResetFormAction.php
subpackage core
Form.php
FormField.php
FormResponse.php
subpackage fields-basic
CheckboxField.php
CheckboxSetField.php
DropdownField.php
GroupedDropdownField.php
ListboxField.php
LookupField.php
NullableField.php
OptionsetField.php
ReadonlyField.php
TextareaField.php
TextField.php
subpackage fields-dataless
DatalessField.php
HeaderField.php
HiddenField.php
LabelField.php
LiteralField.php
ToggleField.php
subpackage fields-datetime
DateField.php
TimeField.php
subpackage fields-files
FileField.php
FileIFrameField.php
ImageField.php
SimpleImageField.php
subpackage fields-formatted
RestrictedTextField.php
subpackage fields-formattedinput
AjaxUniqueTextField.php
AutocompleteTextField.php
ConfirmedPasswordField.php
CreditCardField.php
CurrencyField.php
EmailField.php
HtmlEditorConfig.php
HtmlEditorField.php
NumericField.php
PasswordField.php
PhoneNumberField.php
UniqueRestrictedTextField.php
UniqueTextField.php
subpackage fields-relational
ComplexTableField.php
CountryDropdownField.php
HasManyComplexTableField.php
HasOneComplexTableField.php
LanguageDropdownField.php
ManyManyComplexTableField.php
ScaffoldingComplexTableField.php
TableField.php
TableListField.php
TreeDropdownField.php
TreeMultiselectField.php
TreeSelectorField.php
subpackage fields-structural
CompositeField.php
FieldGroup.php
FieldSet.php
SelectionGroup.php
Tab.php
TabSet.php
ToggleCompositeField.php
subpackage transformations
DisabledTransformation.php
FormTransformation.php
PrintableTransformation.php
ReadonlyTransformation.php
TabularStyle.php
subpackage validators
CustomRequiredFields.php
RequiredFields.php
Validator.php

Class: DropdownField

Source Location: /sapphire/forms/DropdownField.php

Inheritance: Object < ViewableData < RequestHandler < FormField < DropdownField

Summary: Dropdown field, created from a <select> tag.

Methods

public constructor __construct ( $name, [$title = null], [$source = array()], [$value = ""], [$form = null], [$emptyString = null] ) Creates a new dropdown field.
public extraClass ( )
public Field ( ) Returns a <select> tag containing all the appropriate <option> tags.
public getEmptyString ( )
public getHasEmptyDefault ( )
public getSource ( ) Gets the source array including any empty default values.
public isSelected ( )
public performReadonlyTransformation ( )
public setEmptyString ( $str ) Set the default selection label, e.g. "select...".
public setHasEmptyDefault ( $bool )
public setSource ( $source )

Show/hide inherited methods

Inherited Methods

public FormField::__construct()
public FormField::addExtraClass()
public FormField::attrName()
public FormField::attrTitle()
public FormField::attrValue()
public FormField::createTag()
public FormField::dataValue()
public FormField::debug()
public FormField::describe()
public FormField::extraClass()
public FormField::Field()
public FormField::FieldHolder()
public FormField::forTemplate()
public FormField::getCustomValidationMessage()
public FormField::getForm()
public FormField::getTabIndex()
protected FormField::getTabIndexHTML()
public FormField::hasClass()
public FormField::hasData()
public FormField::id()
public FormField::isComposite()
public FormField::isDisabled()
public FormField::isReadonly()
public FormField::jsValidation()
public FormField::LeftTitle()
public FormField::Link()
public FormField::Message()
public FormField::MessageType()
public FormField::Name()
public FormField::name_to_label()
public FormField::performDisabledTransformation()
public FormField::performReadonlyTransformation()
public FormField::removeExtraClass()
public FormField::Required()
public FormField::RightTitle()
public FormField::rootFieldSet()
public FormField::saveInto()
public FormField::securityTokenEnabled()
public FormField::setContainerFieldSet()
public FormField::setCustomValidationMessage()
public FormField::setDisabled()
public FormField::setError()
public FormField::setForm()
public FormField::setLeftTitle()
public FormField::setName()
public FormField::setReadonly()
public FormField::setRightTitle()
public FormField::setTabIndex()
public FormField::setTitle()
public FormField::setValue()
public FormField::SmallFieldHolder()
public FormField::Title()
public FormField::transform()
public FormField::Type()
public FormField::validate()
public FormField::Value()
public RequestHandler::__construct()
public RequestHandler::allowedActions()
public RequestHandler::checkAccessAction()
public RequestHandler::getRequest()
public RequestHandler::handleRequest()
public RequestHandler::hasAction()
public RequestHandler::httpError()
public ViewableData::ATT_val()
public ViewableData::BaseHref()
public ViewableData::buildCastingCache()
public ViewableData::cachedCall()
public ViewableData::castingClass()
public ViewableData::castingHelper()
public ViewableData::castingHelperPair()
public ViewableData::castingObjectCreator()
public ViewableData::castingObjectCreatorPair()
public ViewableData::CSSClasses()
public ViewableData::CurrentMember()
public ViewableData::CurrentPage()
public ViewableData::customise()
public ViewableData::Debug()
public ViewableData::defineMethods()
public ViewableData::escapeTypeForField()
public ViewableData::Even()
public ViewableData::EvenOdd()
public ViewableData::First()
public ViewableData::FirstLast()
public ViewableData::getField()
public ViewableData::getIterator()
public ViewableData::getSecurityID()
public ViewableData::getXMLValues()
public ViewableData::hasField()
public ViewableData::HasPerm()
public ViewableData::hasValue()
public ViewableData::i18nLocale()
public ViewableData::IsAjax()
public ViewableData::iteratorProperties()
public ViewableData::JS_val()
public ViewableData::Last()
public ViewableData::Me()
public ViewableData::Middle()
public ViewableData::MiddleString()
public ViewableData::Modulus()
public ViewableData::MultipleOf()
public ViewableData::obj()
public ViewableData::Odd()
public ViewableData::Pos()
public ViewableData::RAW_val()
public ViewableData::renderWith()
public ViewableData::setCustomisedObj()
public ViewableData::setField()
public ViewableData::SQL_val()
public ViewableData::ThemeDir()
public ViewableData::Top()
public ViewableData::TotalItems()
public ViewableData::XML_val()
public ViewableData::__get()
public ViewableData::__isset()
public ViewableData::__set()
public Object::__construct()
protected Object::addMethodsFrom()
public Object::addStaticVars()
protected Object::addWrapperMethod()
public Object::add_extension()
public Object::add_static_var()
public Object::allMethodNames()
public Object::cacheToFile()
public Object::cacheToFileWithArgs()
public Object::clearCache()
public Object::combined_static()
public Object::create()
protected Object::createMethod()
public Object::create_from_string()
protected Object::defineMethods()
public Object::exists()
public Object::extend()
public Object::extInstance()
public Object::getCustomClass()
public Object::getExtensionInstance()
public Object::getExtensionInstances()
public Object::get_extensions()
public Object::get_static()
public Object::hasExtension()
public Object::hasMethod()
public Object::has_extension()
public Object::invokeWithExtensions()
public Object::is_a()
protected Object::loadCache()
public Object::parentClass()
public Object::parse_class_spec()
public Object::remove_extension()
protected Object::sanitiseCachename()
protected Object::saveCache()
public Object::set_stat()
public Object::set_static()
public Object::set_uninherited()
public Object::stat()
public Object::strong_create()
public Object::uninherited()
public Object::uninherited_static()
public Object::useCustomClass()
public Object::__call()
public Object::__toString()

Variables

protected $disabled
protected $emptyString
protected $hasEmptyDefault
protected $isSelected
protected $source

Show/hide inherited variables

Constants

(none)

Child classes:

CountryDropdownField
A simple extension to dropdown field, pre-configured to list countries.
LookupField
Read-only complement of DropdownField.
ListboxField
Multi-line listbox field, created from a <select> tag.
GroupedDropdownField
Grouped dropdown, using <optgroup> tags.
OptionsetField
Set of radio buttons designed to emulate a dropdown.


Class Details

Dropdown field, created from a <select> tag.

[ Top ]


Class Methods

public __construct

DropdownField __construct( $name $name, [$title $title = null], [$source $source = array()], [$value $value = ""], [$form $form = null], [$emptyString $emptyString = null])

[line 53]

Creates a new dropdown field.

Overrides FormField::__construct() (Create a new field.)

Parameters:

  • $name $name - The field name
  • $title $title - The field title
  • $source $source - An map of the dropdown items
  • $value $value - The current value
  • $form $form - The parent form
  • $emptyString $emptyString - mixed Add an empty selection on to of the $source-Array (can also be boolean, which results in an empty string) Argument is deprecated in 2.3, please use setHasEmptyDefault() and setEmptyString() instead.

[ Top ]

public extraClass

void extraClass( )

[line 187]

Overrides FormField::extraClass() (Compiles all CSS-classes. Optionally includes a "nolabel"-class if no title was set on the formfield.)

[ Top ]

public Field

string Field( )

[line 69]

Returns a <select> tag containing all the appropriate <option> tags.

Makes use of FormField->createTag() to generate the <select> tag and option elements inside is as the content of the <select>.

  • return HTML tag for this dropdown field
Overrides FormField::Field() (Returns the form field - used by templates.)

[ Top ]

public getEmptyString

string getEmptyString( )

[line 175]

[ Top ]

public getHasEmptyDefault

boolean getHasEmptyDefault( )

[line 156]

[ Top ]

public getSource

array getSource( )

[line 131]

Gets the source array including any empty default values.

Overridden in child classes as:
LookupField::getSource()

[ Top ]

public isSelected

boolean isSelected( )

[line 122]

[ Top ]

public performReadonlyTransformation

void performReadonlyTransformation( )

[line 179]

Overrides FormField::performReadonlyTransformation() (Returns a readonly version of this field)

[ Top ]

public setEmptyString

void setEmptyString( string $str)

[line 167]

Set the default selection label, e.g. "select...".

Defaults to an empty string. Automatically sets $hasEmptyDefault to true.

Parameters:

  • string $str -

[ Top ]

public setHasEmptyDefault

void setHasEmptyDefault( boolean $bool)

[line 149]

Parameters:

  • boolean $bool -

[ Top ]

public setSource

void setSource( array $source)

[line 142]

Parameters:

  • array $source -

[ Top ]


Class Variables

protected static $disabled

[line 26]

Type: boolean

Overrides: Array

[ Top ]

protected static $emptyString =  ''

[line 40]

  • var The title shown for an empty default selection, e.g. "Select...".

Type: string

[ Top ]

protected static $hasEmptyDefault =  false

[line 34]

  • var Show the first <option> element as empty (not having a value), with an optional label defined through $emptyString. By default, the <select> element will be rendered with the first option from $source selected.

Type: boolean

[ Top ]

protected static $isSelected

[line 21]

  • var Determines if the field was selected at the time it was rendered, so if $value matches on of the array values specified in $source

Type: boolean

[ Top ]

protected static $source

[line 14]

  • var Associative or numeric array of all dropdown items, with array key as the submitted field value, and the array value as a natural language description shown in the interface element.

Type: boolean

[ Top ]

Comments

Please use comments for notes, tips and corrections about the described functionality.
Use the Silverstripe Forum to ask questions.

blog comments powered by Disqus