2008-09-29 05:18:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* EditableDateField
|
2009-04-17 04:26:40 +02:00
|
|
|
*
|
2008-09-29 05:18:23 +02:00
|
|
|
* Allows a user to add a date field to the Field Editor
|
2009-04-17 04:26:40 +02:00
|
|
|
*
|
|
|
|
* @package userforms
|
2008-09-29 05:18:23 +02:00
|
|
|
*/
|
|
|
|
class EditableDateField extends EditableFormField {
|
|
|
|
static $singular_name = 'Date field';
|
|
|
|
static $plural_name = 'Date fields';
|
|
|
|
|
|
|
|
function DefaultField() {
|
|
|
|
$dmyField = new CalendarDateField( "Fields[{$this->ID}][Default]", "", $this->getField('Default') );
|
|
|
|
|
|
|
|
if( $this->readonly )
|
|
|
|
$dmyField = $dmyField->performReadonlyTransformation();
|
|
|
|
|
|
|
|
return $dmyField;
|
|
|
|
}
|
|
|
|
|
2009-04-17 04:26:40 +02:00
|
|
|
function populateFromPostData($data) {
|
2008-09-29 05:18:23 +02:00
|
|
|
$fieldPrefix = 'Default-';
|
|
|
|
|
|
|
|
if( empty( $data['Default'] ) && !empty( $data[$fieldPrefix.'Year'] ) && !empty( $data[$fieldPrefix.'Month'] ) && !empty( $data[$fieldPrefix.'Day'] ) )
|
|
|
|
$data['Default'] = $data['Year'] . '-' . $data['Month'] . '-' . $data['Day'];
|
|
|
|
|
|
|
|
// Debug::show( $data );
|
|
|
|
|
|
|
|
parent::populateFromPostData( $data );
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFormField() {
|
|
|
|
return new CalendarDateField( $this->Name, $this->Title, $this->getField('Default') );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|