Version: current

# Class DatePickerField

Form field to display an editable date string, either in a single `<input type="text">` field, or in three separate fields for day, month and year.

# Configuration

- 'showcalendar' (boolean): Determines if a calendar picker is shown. By default, "DHTML Calendar" is used,see http://www.dynarch.com/projects/calendar. CAUTION: Only works in NZ date format, see calendar-setup.js

  CAUTION: Might not be useable in combination with 'showcalendar', depending on the used javascript library

- 'dateformat' (string): Date format compatible with Zend_Date. Usually set to default format for `DateField::$locale` through Zend_Locale_Format::getDateFormat().
- 'datavalueformat' (string): Internal ISO format string used by `DatePickerField::dataValue()` to save the date to a database.
- 'min' (string): Minimum allowed date value (in ISO format, or strtotime() compatible). Example: '2010-03-31', or '-7 days'
- 'max' (string): Maximum allowed date value (in ISO format, or strtotime() compatible). Example: '2010-03-31', or '1 year'

# Localization

The field will get its default locale from `i18n::get_locale()`, and set the `dateformat` configuration accordingly. Changing the locale through `DateField::setLocale()` will not update the `dateformat` configuration automatically.

# Usage

# Example: German dates with separate fields for day, month, year

$f = new DateField('MyDate'); $f->setLocale('de_DE');

# Validation

Caution: JavaScript validation is only supported for the 'en_NZ' locale at the moment, it will be disabled automatically for all other locales.

  Object
  ViewableData implements IteratorAggregate
  RequestHandler
  FormField
  TextField
  DateField
  DatePickerField

Package: forms\fields-datetime
Located at dataobject_manager/code/date_picker_field/DatePickerField.php

## Methods summary

`public static` | # `HTMLField( mixed $id, mixed $name, mixed $val )`
`public static` | # `set_date_format( mixed $format )`
`public static` | # `dmy( )`
`public static` | # `mdy( )`
`public` | # `setValue( String|Array $val )` Sets the internal value to ISO date format. Sets the internal value to ISO date format. #### Parameters $val String|Array $val #### Overrides `DateField::setValue`
`public String` | # `dataValue( )` #### Returns `String` ISO 8601 date, suitable for insertion into database #### Overrides `DateField::dataValue`
`public` | # `Field( )` Returns the form field - used by templates. Although FieldHolder is generally what is inserted into templates, all of the field holder templates make use of $Field. It's expected that FieldHolder will give you the "complete" representation of the field on the form, whereas Field will give you the core editing widget, such as an input tag. Returns the form field - used by templates. Although FieldHolder is generally what is inserted into templates, all of the field holder templates make use of $Field. It's expected that FieldHolder will give you the "complete" representation of the field on the form, whereas Field will give you the core editing widget, such as an input tag. Our base FormField class just returns a span containing the value. This should be overridden! #### Overrides `DateField::Field`

### Methods inherited from DateField

`ShowCalendar()`, `__construct()`, `getCalendarLang()`, `getConfig()`, `getLocale()`, `jsValidation()`, `performReadonlyTransformation()`, `setConfig()`, `setLocale()`, `validate()`

### Methods inherited from TextField

`InternallyLabelledField()`, `getMaxLength()`, `setMaxLength()`

### Methods inherited from FormField

`FieldHolder()`, `LeftTitle()`, `Link()`, `Message()`, `MessageType()`, `Name()`, `Required()`, `RightTitle()`, `SmallFieldHolder()`, `Title()`, `Type()`, `Value()`, `addExtraAttribute()`, `addExtraClass()`, `allowHTML5()`, `allow_html5()`, `attrName()`, `attrTitle()`, `attrValue()`, `createTag()`, `debug()`, `describe()`, `extraClass()`, `fieldHolderTemplates()`, `fieldTemplates()`, `forTemplate()`, `getCustomValidationMessage()`, `getExtraClasses()`, `getForm()`, `getHTML5Attribute()`, `getTabIndex()`, `getTabIndexHTML()`, `hasClass()`, `hasData()`, `id()`, `isComposite()`, `isDisabled()`, `isReadonly()`, `name_to_label()`, `performDisabledTransformation()`, `removeExtraAttribute()`, `removeExtraClass()`, `rootFieldSet()`, `saveInto()`, `securityTokenEnabled()`, `setAutocomplete()`, `setContainerFieldSet()`, `setCustomValidationMessage()`, `setDisabled()`, `setError()`, `setFieldHolderTemplate()`, `setForm()`, `setHTML5Attribute()`, `setLeftTitle()`, `setName()`, `setReadonly()`, `setRightTitle()`, `setSmallFieldHolderTemplate()`, `setTabIndex()`, `setTemplate()`, `setTitle()`, `smallFieldHolderTemplates()`, `transform()`, `useHTML5()`, `use_html5()`

### Methods inherited from RequestHandler

`allowedActions()`, `checkAccessAction()`, `getRequest()`, `handleRequest()`, `hasAction()`, `httpError()`

### Methods inherited from ViewableData

`ATT_val()`, `BaseHref()`, `CSSClasses()`, `ColumnBreak()`, `ColumnCalc()`, `ColumnNumber()`, `ColumnPad()`, `ColumnPos()`, `CurrentMember()`, `CurrentPage()`, `Debug()`, `Even()`, `EvenOdd()`, `First()`, `FirstLast()`, `HasPerm()`, `IsAjax()`, `JS_val()`, `Last()`, `Me()`, `Middle()`, `MiddleString()`, `Modulus()`, `MultipleOf()`, `Odd()`, `Pos()`, `RAW_val()`, `SQL_val()`, `ThemeDir()`, `ThemeName()`, `Top()`, `TotalItems()`, `XML_val()`, `__get()`, `__isset()`, `__set()`, `buildCastingCache()`, `cachedCall()`, `castingClass()`, `castingHelper()`, `castingHelperPair()`, `castingObjectCreator()`, `castingObjectCreatorPair()`, `customise()`, `defineMethods()`, `escapeTypeForField()`, `getField()`, `getIterator()`, `getSecurityID()`, `getXMLValues()`, `hasField()`, `hasValue()`, `i18nLocale()`, `iteratorProperties()`, `obj()`, `renderWith()`, `setCustomisedObj()`, `setField()`

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `exists()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`public static string` | $dateFormat | #

### Properties inherited from DateField

`$config`, `$locale`, `$valueObj`

### Properties inherited from TextField

`$maxLength`

### Properties inherited from FormField

`$autocomplete`, `$containerFieldSet`, `$customValidationMessage`, `$description`, `$disabled`, `$dontEscape`, `$extraAttributes`, `$extraClass`, `$extraClasses`, `$fieldHTML5`, `$fieldHolderTemplate`, `$form`, `$html5Attributes`, `$leftTitle`, `$message`, `$messageType`, `$name`, `$possible_autocomplete_values`, `$readonly`, `$rightTitle`, `$smallFieldHolderTemplate`, `$tabIndex`, `$template`, `$title`, `$use_html5`, `$value`

### Properties inherited from RequestHandler

`$allowed_actions`, `$brokenOnConstruct`, `$request`, `$url_handlers`

### Properties inherited from ViewableData

`$casting`, `$customisedObject`, `$default_cast`, `$failover`, `$iteratorPos`, `$iteratorTotalItems`

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -