silverstripe-framework/forms/CalendarDateField.php
Ingo Schommer 9e98f127f2 Merged revisions 47613 via svnmerge from
svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq

........
  r47613 | ischommer | 2008-01-04 19:14:58 +1300 (Fri, 04 Jan 2008) | 1 line
  
  adding tabIndex capabilities, switching HTML-rendering to createTag()
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@52199 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-04-06 04:08:45 +00:00

55 lines
1.3 KiB
PHP
Executable File

<?php
/**
* @package forms
* @subpackage fields-datetime
*/
/**
* This field creates a date field that shows a calendar on pop-up
* @package forms
* @subpackage fields-datetime
*/
class CalendarDateField extends DateField {
protected $futureOnly;
static function HTMLField( $id, $name, $val ) {
return <<<HTML
<input type="text" id="$id" name="$name" value="$val" />
<img src="sapphire/images/calendar-icon.gif" id="$id-icon" />
<div class="calendarpopup" id="$id-calendar"></div>
HTML;
}
function Field() {
Requirements::javascript("jsparty/calendar/calendar.js");
Requirements::javascript("jsparty/calendar/lang/calendar-en.js");
Requirements::javascript("jsparty/calendar/calendar-setup.js");
Requirements::css("sapphire/css/CalendarDateField.css");
Requirements::css("jsparty/calendar/calendar-win2k-1.css");
$field = parent::Field();
$id = $this->id();
$val = $this->attrValue();
$futureClass = $this->futureOnly ? ' futureonly' : '';
$innerHTML = self::HTMLField( $id, $this->name, $val );
return <<<HTML
<div class="calendardate$futureClass">
$innerHTML
</div>
HTML;
}
/**
* Sets the field so that only future dates can be set on them
*/
function futureDateOnly() {
$this->futureOnly = true;
}
}
?>