Yii 1.1: calendar

A widget based on 'The Coolest DHTML Calendar'

This extension is a calendar based on The Coolest DHTML Calendar
It's an easy to use, light and fast calendar with many options




  • Yii 1.0 or above


  • Extract the release file under protected/extensions


Check here the complete documentation of the calendar


See the following code example: A calendar that appears when an image is clicked

<?php echo CHtml::activeLabelEx($event,'start_date'); ?>
<?php echo CHtml::activeTextField($event,'start_date',array("id"=>"start_date")); ?>
<?php echo CHtml::image("images/images.jpg","calendar",
array("id"=>"c_button","class"=>"pointer")); ?>
    &nbsp;(calendar appears when image is clicked)
    <?php $this->widget('application.extensions.calendar.SCalendar',

A calendar that appears when a textfield is clicked

<?php echo CHtml::activeLabelEx($event,'end_date'); ?>
    <?php echo CHtml::activeTextField($event,'end_date',array("id"=>"end_date")); ?>
    &nbsp;(calendar appears when textbox is clicked)
    <?php $this->widget('application.extensions.calendar.SCalendar',

A fixed position calendar displaying date and time with a range of 2008-2010

<?php echo CHtml::activeLabelEx($event,'remind'); ?>
    <?php echo CHtml::activeTextField($event,'remind',array("id"=>"remind")); ?>
    &nbsp;(calendar with time , position 400,200 and a range 2008-2010)
    <?php $this->widget('application.extensions.calendar.SCalendar',
       'ifFormat'=>'%Y-%m-%d %H:%M',

Change Log

August 18, 2009

Version 1.22
Fixed javascript error caused by boolean parameters (thanks to fhelix72) Added step parameter for the years displayed in the calendar's year drop down menu (thanks to fhelix72)

July 16, 2009

Version 1.21
bug fix (handling undefined variables)

June 23, 2009

Version 1.2
Fixed bug with flatCallback, onSelect, onClose and onUpdate functions

June 2, 2009

Version 1.1
Fixes a bug with IE that made the widget useless

May 29, 2009

  • Initial release.

Total 19 comments

#7693 report it
@RT at 2012/04/10 04:16am

Hey I am using the following Code:

<?php echo CHtml::activeLabelEx($event,'end_date'); ?> <?php echo CHtml::activeTextField($event,'end_date',array("id"=>"end_date")); ?>  (calendar appears when textbox is clicked) <?php $this->widget('application.extensions.calendar.SCalendar', array( 'inputField'=>'end_date', 'ifFormat'=>'%Y-%m-%d', )); ?>

I got the error that 'undefined variable: event'...So how to fix it??

#5989 report it
VladimirV at 2011/12/03 07:27am
Plain calendar

Hello, Tell me please, how can I make the calendar be always displayed on the screen, allowing the user to select a date? Thanks

#5988 report it
VladimirV at 2011/12/03 05:15am
Just 2 points
  1. If you get some error messages when you first copy the calendar folder into your extensions folder. Make sure to set the right permissions (in Linux).

  2. When you use it with CActive form, make sure not to include the array("id"=>"idoffield") and to set the 'inputField' config parameter to be the auto generated id of the field you refer to (this is usually FormName_fieldName).

Thank you

#4917 report it
Nirav at 2011/08/29 06:24am
change default date

How to change default date in this extension? It is displaying current date by default right now

I want to change it with my custom date as default date. How can I do this?

#2592 report it
el chief at 2011/01/20 03:46pm
Looks like a datepicker not a calendar

a calendar is more like google's calendar, whereas a datepicker is for picking a date in a form field

#521 report it
mirrorps at 2010/05/05 07:43pm
Powerfull and easy to integrate extension!

Congrats on the extension! Super easy to use and a very powerful functionality ... For those that are in a hurry and getting the error, about the undefined variable, just delete ('skin'=>$skin, 'stylesheet'=>$style) to use the default styling.

Congrats again!

#994 report it
mauphung at 2010/01/13 09:35am
More guide please

Please give me just one full working example with following missing data for: $event = ? $skin = ? ("aqua"?) $style = ? ("blue"?) Thanks,

#996 report it
jwerner at 2010/01/13 05:49am
Language Property


I think you shouldf add the following code at ca. line 509 in SCalendar.php:

if(isset ($this->_language)) $prop .= "language : '$this->_language',\n";



#1236 report it
Spyros at 2009/10/18 03:07am
Is It a bug?

Hi, What is the value of the $style and $skin you use? Also check the jscalendar's home page to see if the bug happens there too. http://www.dynarch.com/static/jscalendar-1.0/simple-1.html

If you have any other questions please post them in the forum thread http://www.yiiframework.com/forum/index.php?/topic/2337-extension-calendar/

#1237 report it
Junior - df9 at 2009/10/17 05:14pm
is it a bug?

Hey, guys,

I'm using the following code:

<?php echo CHtml::activeLabelEx($model,'promotionDateStart'); ?> <?php echo CHtml::activeTextField($model,'promotionDateStart',array('id'=>'promotionDateStart')); ?> <?php echo CHtml::image(Yii::app()->baseUrl."/images/site/calendar.jpg","calendar", array("id"=>"ds_button","class"=>"pointer")); ?> <?php $this->widget('application.extensions.calendar.SCalendar', array( 'inputField'=>'promotionDateStart', 'button'=>'ds_button', 'skin'=>$skin, 'stylesheet'=>$style, 'ifFormat'=>'%Y-%m-%d', 'range'=>'[2000,2050]', 'cache'=>true, //'showOthers'=>false, //'showsTime'=>false, //'timeFormat'=>'24', 'language'=>'br', )); ?>

Yii 1.0.9, Linux, Firefox 3.5

The calendar object is shown fine, but 17th, October (today) is shown twice, in Saturday and Sunday...and it changes all the rest of month...any idea on how to solve this bug?


#1452 report it
fhelix72 at 2009/07/30 04:27pm
To use Step Parameter

If you want to manage the 'Step' parameter that is contemplated in DHTML Calendar for change the step between years in the drop down list (default=2) you must make these changes to SCalendar.php:

In the begin add to the other parameters: /* @var $_step Integer private $_step;

Add this new function: /*** * @param integer $step */ public function setStep($step) { if(is_numeric($step) && ($step >-1)) { $this->_step = $step; } else { $this->_step = 2; } }

Add in createMarkup function: if(isset ($this->_step)) $prop .= "step : $this->_step,\n";

#1453 report it
fhelix72 at 2009/07/30 03:15pm
Error in SCalendar.php for boolean parameters

I found that all the boolean parameters causes a javascript error if they are used (true or false), they are: singleClick, weekNumbers, showsTime, electric, cache, showOthers The problem is that they must be passed to js surrounded by '' So you should substitute in the createMarkup function of SCalendar.php the 6 rows of the above parameters from:

if(isset ($this->_PARAMETER))     $prop .= "PARAMETER       :  $this->_PARAMETER,\n";


if(isset ($this->_PARAMETER))     $prop .= "PARAMETER       :  '$this->_PARAMETER',\n";
#1484 report it
nasrul at 2009/07/21 07:23pm
I do love this thing

WOW.!! Thank you so much to the Author

#1562 report it
Spyros at 2009/06/23 01:03am

There was an error in the SCalendar.php You should change line 486 from

if(isset ($this->_flatCallback))  $prop .= "flatCallback    : '$this->_flatCallback',\n";


if(isset ($this->_flatCallback))  $prop .= "flatCallback    : $this->_flatCallback,\n";

Then the calendar has to be a flat one Then use this code

<script type="text/javascript">
  function dateChanged(calendar) {
    // Beware that this function is called even if the end-user only
    // changed the month/year.  In order to determine if a date was
    // clicked you can use the dateClicked property of the calendar:
    if (calendar.dateClicked) {
      // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
      var y = calendar.date.getFullYear();
      var m = calendar.date.getMonth();     // integer, 0..11
      var d = calendar.date.getDate();      // integer, 1..31
      // redirect...
      window.location = "/" + y + "/" + m + "/" + d + "/index.php";
<div id="calendar-container"></div>
 <?php $this->widget('application.extensions.calendar.SCalendar',
        'flat'=> 'calendar-container',
#1572 report it
Deepak Pradhan at 2009/06/20 06:41pm
My BAD, this version is under LGPL

Now wondering how to use this?

function dateChanged(calendar) {

if (calendar.dateClicked) {

  var y = calendar.date.getFullYear();

  var m = calendar.date.getMonth();   

  var d = calendar.date.getDate();    

  window.location = "/" + y + "/" + m + "/" + d + "/index.php";

#1573 report it
Deepak Pradhan at 2009/06/20 05:45pm
Not free for comercial use

Liked it and planed to use for the flat & flatCallback options it provides, but ..

#1632 report it
phreak at 2009/05/29 07:13am

really good calendar. having time editing is really cool. 10x :)

#1633 report it
tommytomtom at 2009/05/29 06:12am
The "better" date picker

This "calendar" is much better in my opinion then the only other viable alternative, jui.EDatePicker.

The EDatePicker although useable with some minor code modifications, is really very basic with a crude graphical user interface.

This calendar however offers EVERYTHING and it works great without any modifications. The graphical user interface is intuitive and very advanced as well as easy to control. Thanks!

#1634 report it
horizons at 2009/05/29 03:59am
really good calendar extension

really good calendar extension

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: Spyros
  • Category: User Interface
  • Votes: +21 / -2
  • Downloaded: 8,249 times
  • Created on: May 29, 2009
  • Last updated: May 14, 2010