Class DateField
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, jQuery UI datepicker is used (see
DateField_View_JQuery). - 'jslocale' (string): Overwrites the "Locale" value set in this class. Only
useful in combination with
DateField_View_JQuery. - 'dmyfields' (boolean): Show three input fields for day, month and year separately. 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::$localethrough Zend_Locale_Format::getDateFormat(). - 'datavalueformat' (string): Internal ISO format string used by
DateField::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'); $f->setConfig('dmyfields');
# 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
Direct known subclasses
Methods summary
public
|
#
__construct(
Returns an input field, class="text" and type="text" with an optional maxlength |
public
|
#
FieldHolder( )
Returns a "Field Holder" for this field - used by templates. Forms are constructed from by concatenating a number of these field holders. The default field holder is a label and form field inside a paragraph tag. |
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. |
public
|
|
public
String
|
|
public
|
|
public
|
#
jsValidation( )
javascript handler Functions for each field type by default formfield doesnt have a validation function |
public
boolean
|
#
validateArrayValue( Array $val )
Validate an array with expected keys 'day', 'month' and 'year. Used because Zend_Date::isDate() doesn't provide this. |
public
|
|
public
string
|
|
public
|
|
public
|
|
public
mixed
|
Methods inherited from TextField
InternallyLabelledField(),
getMaxLength(),
setMaxLength()
Methods inherited from FormField
LeftTitle(),
Link(),
Message(),
MessageType(),
Name(),
Required(),
RightTitle(),
SmallFieldHolder(),
Title(),
Type(),
Value(),
addExtraClass(),
attrName(),
attrTitle(),
attrValue(),
createTag(),
debug(),
describe(),
extraClass(),
forTemplate(),
getCustomValidationMessage(),
getForm(),
getTabIndex(),
getTabIndexHTML(),
hasClass(),
hasData(),
id(),
isComposite(),
isDisabled(),
isReadonly(),
name_to_label(),
performDisabledTransformation(),
removeExtraClass(),
rootFieldSet(),
saveInto(),
securityTokenEnabled(),
setContainerFieldSet(),
setCustomValidationMessage(),
setDisabled(),
setError(),
setForm(),
setLeftTitle(),
setName(),
setReadonly(),
setRightTitle(),
setTabIndex(),
setTitle(),
transform()
Methods inherited from RequestHandler
allowedActions(),
checkAccessAction(),
getRequest(),
handleRequest(),
hasAction(),
httpError()
Methods inherited from ViewableData
ATT_val(),
BaseHref(),
CSSClasses(),
CurrentMember(),
CurrentPage(),
Debug(),
Even(),
EvenOdd(),
First(),
FirstLast(),
HasPerm(),
IsAjax(),
JS_val(),
Last(),
Me(),
Middle(),
MiddleString(),
Modulus(),
MultipleOf(),
Odd(),
Pos(),
RAW_val(),
SQL_val(),
ThemeDir(),
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(),
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
protected
array
|
$config | |
protected
String
|
$locale | |
protected
Zend_Date
|
$valueObj |
#
Just set if the date is valid. |
Properties inherited from TextField
Properties inherited from FormField
$containerFieldSet,
$customValidationMessage,
$description,
$disabled,
$dontEscape,
$extraClass,
$extraClasses,
$form,
$leftTitle,
$message,
$messageType,
$name,
$readonly,
$rightTitle,
$tabIndex,
$title,
$value
Properties inherited from RequestHandler
$allowed_actions,
$brokenOnConstruct,
$request,
$url_handlers
Properties inherited from ViewableData
$casting,
$customisedObject,
$default_cast,
$failover,
$iteratorPos,
$iteratorTotalItems
Comments
Use the Silverstripe Forum to ask questions.