EJuiTimePicker
EJuiTimePicker is an axtension for Yii framework. This extension is a wrapper for Timepicker addon which adds a timepicker to jQuery UI Datepicker.
This extension is based on CJuiDateTimePicker extension, hovewer it has different widget call (prefix of 'C' might get confusing in the future) and few other tricks up its sleeve.
Move EJuiTimePicker folder in your applications extensions folder (default: protected/extensions).
Just place the following code inside your view file:
$this->widget( 'ext.EJuiTimePicker.EJuiTimePicker', array( 'model' => $model, // Your model 'attribute' => 'end_date', // Attribute for input ));
You can also change some default settings (more on this later).
To make your life easier, you can configure widgetFactory component with some default options (all the options can be set for widget which will overwrite widgetFactory option). Change your main.php config file to look similarly to this:
'components' => array( 'widgetFactory' => array( 'widgets' => array( 'EJuiTimePicker' => array( 'options' => array( 'dateFormat' => 'yy-mm-dd', 'showOn' => 'both', 'buttonText' => 'Open calendar', // Any other option from http://jqueryui.com/demos/datepicker/ // Or http://trentrichardson.com/examples/timepicker/ ), 'timeOptions' => array( 'showOn' => 'focus', ), 'htmlOptions' => array( 'autocomplete' => 'off', 'size' => 10, 'maxlength' => 10, ), 'timeHtmlOptions' => array( 'size' => 5, 'maxlength' => 5, ), 'language' => 'lt', 'mode' => 'date', ), ), ), ),
date (will add only date picker), time (will add only time picker), datetime (will add both. This is default value).
Total 5 comments
Just remove or committe 'language' => 'en'
When language is set to 'en' in configuration (main.php), EJuiTimePicker displaying Simplified Chinese characters.
To resolve localization issue you can restore the default localizations with: $.datepicker.setDefaults($.datepicker.regional['']); (Please check stackoverflow discussion for more detail.)
So, to resolve localization issue in extension simply replace line 92 with:
if you are getting somethign like this Uncaught RangeError: Maximum call stack size exceeded and you are using in one same form zii.widgets.jui.CJuiDatePicker and ext.EJuiTimePicker.EJuiTimePicker
Then you might loose a lot of time (like me) before notcing the timepicker lib is loaded twice on as the classic version and the other as the minified , which runs into conflict the solution is to simply comment out the js lib loading in the less generic widget $cs->registerScriptFile( $assets . self::ASSETS_NAME . '.js',CClientScript::POS_END );
hope this helps someone
Hi when using the module as timepicker localisation didn't because the regional settings was fixed on datepicker but should be relevant to $this->mode
simply replace this , line 92 datepicker by {$this->mode}picker
$js = "$('#{$id}').{$this->mode}picker($.extend({showMonthAfterYear:false}, $.{$this->mode}picker.regional['{$this->language}'], {$options}));');";
uncaught exception: Missing instance data for this datepicker ???
Leave a comment
Please login to leave your comment.