public static function calendar($name, $value = null, $options = array())
	{
		static $done;

		if ($done === null)
		{
			$done = array();
		}

		$readonly = isset($options['readonly']) && $options['readonly'] == 'readonly';
		$disabled = isset($options['disabled']) && $options['disabled'] == 'disabled';
		$time     = isset($options['time']) ? (bool)$options['time'] : true;

		$format = 'yy-mm-dd';
		if (isset($options['format']))
		{
			$format = $options['format'] ? $options['format'] : $format;
			unset($options['format']);
		}

		if (!isset($options['class']))
		{
			$options['class'] = 'calendar-field';
		}
		else
		{
			$options['class'] = ' calendar-field';
		}

		if (!$readonly && !$disabled)
		{
			// Load the calendar behavior
			Behavior::calendar();
			Behavior::tooltip();

			$id = self::getIdAttribute($name, $options);

			// Only display the triggers once for each control.
			if (!in_array($id, $done))
			{
				if ($format == 'Y-m-d H:i:s' || $format == '%Y-%m-%d %H:%M:%S')
				{
					$time = true;
				}
				$altformats = array('Y-m-d H:i:s', '%Y-%m-%d %H:%M:%S', 'Y-m-d', '%Y-%m-%d');

				$format = (in_array($format, $altformats) ? 'yy-mm-dd' : $format);

				\App::get('document')->addScriptDeclaration("
					jQuery(document).ready(function($){
						" . ($time ? "$('#" . $id . "').datetimepicker({" : "$('#" . $id . "').datepicker({") . "
							duration: '',
							showTime: true,
							constrainInput: false,
							stepMinutes: 1,
							stepHours: 1,
							altTimeField: '',
							time24h: true,
							dateFormat: '" . $format . "'" . ($time ? ", timeFormat: 'HH:mm:00'" : "") . "
						});
					});
				");

				$done[] = $id;
			}

			return '<span class="input-datetime">' . self::text($name, $value, $options) . '</span>';
		}
		else
		{
			$value = (0 !== (int) $value ? with(new Date($value))->format('Y-m-d H:i:s') : '');

			return self::text($name . 'disabled', (0 !== (int) $value ? with(new Date($value))->format('Y-m-d H:i:s') : ''), $options) .
				   self::hidden($name, $value, $options);
		}
	}
public static function calendar($name, $value = null, $options = array())
	{
		static $done;

		if ($done === null)
		{
			$done = array();
		}

		$readonly = isset($options['readonly']) && $options['readonly'] == 'readonly';
		$disabled = isset($options['disabled']) && $options['disabled'] == 'disabled';
		$time     = isset($options['time']) ? (bool)$options['time'] : true;

		$format = 'yy-mm-dd';
		if (isset($options['format']))
		{
			$format = $options['format'] ? $options['format'] : $format;
			unset($options['format']);
		}

		if (!isset($options['class']))
		{
			$options['class'] = 'calendar-field';
		}
		else
		{
			$options['class'] = ' calendar-field';
		}

		if (!$readonly && !$disabled)
		{
			// Load the calendar behavior
			Behavior::calendar();
			Behavior::tooltip();

			$id = self::getIdAttribute($name, $options);

			// Only display the triggers once for each control.
			if (!in_array($id, $done))
			{
				if ($format == 'Y-m-d H:i:s' || $format == '%Y-%m-%d %H:%M:%S')
				{
					$time = true;
				}
				$altformats = array('Y-m-d H:i:s', '%Y-%m-%d %H:%M:%S', 'Y-m-d', '%Y-%m-%d');

				$format = (in_array($format, $altformats) ? 'yy-mm-dd' : $format);

				\App::get('document')->addScriptDeclaration("
					jQuery(document).ready(function($){
						" . ($time ? "$('#" . $id . "').datetimepicker({" : "$('#" . $id . "').datepicker({") . "
							duration: '',
							showTime: true,
							constrainInput: false,
							stepMinutes: 1,
							stepHours: 1,
							altTimeField: '',
							time24h: true,
							dateFormat: '" . $format . "'" . ($time ? ", timeFormat: 'HH:mm:00'" : "") . "
						});
					});
				");

				$done[] = $id;
			}

			return '<span class="input-datetime">' . self::text($name, $value, $options) . '</span>';
		}
		else
		{
			$value = (0 !== (int) $value ? with(new Date($value))->format('Y-m-d H:i:s') : '');

			return self::text($name . 'disabled', (0 !== (int) $value ? with(new Date($value))->format('Y-m-d H:i:s') : ''), $options) .
				   self::hidden($name, $value, $options);
		}
	}
public static function calendar ( $ name , $ value = null , $ options = array ( ) ) { static $ done ; if ( $ done === null ) { $ done = array ( ) ; } $ readonly = isset ( $ options [ 'readonly' ] ) && $ options [ 'readonly' ] == 'readonly' ; $ disabled = isset ( $ options [ 'disabled' ] ) && $ options [ 'disabled' ] == 'disabled' ; $ time = isset ( $ options [ 'time' ] ) ? ( bool ) $ options [ 'time' ] : true ; $ format = 'yy-mm-dd' ; if ( isset ( $ options [ 'format' ] ) ) { $ format = $ options [ 'format' ] ? $ options [ 'format' ] : $ format ; unset ( $ options [ 'format' ] ) ; } if ( ! isset ( $ options [ 'class' ] ) ) { $ options [ 'class' ] = 'calendar-field' ; } else { $ options [ 'class' ] = ' calendar-field' ; } if ( ! $ readonly && ! $ disabled ) { // Load the calendar behavior Behavior :: calendar ( ) ; Behavior :: tooltip ( ) ; $ id = self :: getIdAttribute ( $ name , $ options ) ; // Only display the triggers once for each control. if ( ! in_array ( $ id , $ done ) ) { if ( $ format == 'Y-m-d H:i:s' || $ format == '%Y-%m-%d %H:%M:%S' ) { $ time = true ; } $ altformats = array ( 'Y-m-d H:i:s' , '%Y-%m-%d %H:%M:%S' , 'Y-m-d' , '%Y-%m-%d' ) ; $ format = ( in_array ( $ format , $ altformats ) ? 'yy-mm-dd' : $ format ) ; \ App :: get ( 'document' ) -> addScriptDeclaration ( "
					jQuery(document).ready(function($){
						" . ( $ time ? "$('#" . $ id . "').datetimepicker({" : "$('#" . $ id . "').datepicker({" ) . "
							duration: '',
							showTime: true,
							constrainInput: false,
							stepMinutes: 1,
							stepHours: 1,
							altTimeField: '',
							time24h: true,
							dateFormat: '" . $ format . "'" . ( $ time ? ", timeFormat: 'HH:mm:00'" : "" ) . "
						});
					});
				" ) ; $ done [ ] = $ id ; } return '<span class="input-datetime">' . self :: text ( $ name , $ value , $ options ) . '</span>' ; } else { $ value = ( 0 !== ( int ) $ value ? with ( new Date ( $ value ) ) -> format ( 'Y-m-d H:i:s' ) : '' ) ; return self :: text ( $ name . 'disabled' , ( 0 !== ( int ) $ value ? with ( new Date ( $ value ) ) -> format ( 'Y-m-d H:i:s' ) : '' ) , $ options ) . self :: hidden ( $ name , $ value , $ options ) ; } }
Displays a calendar control field

@param   string  $name
@param   string  $value
@param   array   $options
@return  string  HTML markup for a calendar field
Displays a calendar control field