The DatePickerPlugin handles an input field with a pop-up calendar to select a date for use in TWiki forms and TWiki applications. The plugin is based on the Mishoo JSCalendar, a DHTML pop-up calendar. The date format can be customized.
ATTENTION: This plugin replaces the JSCalendarContrib. The DatePickerPlugin and older versions of the JSCalendarContrib do not coexist. Before using the DatePickerPlugin, uninstall the JSCalendarContrib, or upgrade the contrib to version 2012-12-12 or later.
This package adds a date
type to TWikiForms:
|
|||||||||
Example form definition:
|
|||||||||||
You can also use the date picker directly in your HTML forms, without having to write any code. Just include this in the topic text:
<form action="..."> %DATEPICKER{ name="Start_date" value="2025-03-15" }% <form>This will show an HTML input field named "Start_date" and a button to popup a calendar to select a date.
|
|||||||||||||||||||||||||||||||||
Test: (this only works if the DatePickerPlugin is installed and enabled)
Read the Mishoo documentation or visit the demo page for detailed information on using the calendar widget.
This plugin includes the following function to make using the calendar easier from other TWiki plugins:
TWiki::Plugins::DatePickerPlugin::renderForEdit( $name, $value, $format [, \%options] ) -> $html
This is the simplest way to use calendars from a plugin.
$name
is the name of the CGI parameter for the calendar (it should be unique),
$value
is the current value of the parameter (may be undef)
$format
is the format to use (optional; the default is set in configure
). The HTML returned will display a date field and a drop-down calendar.
\%options
is an optional hash containing base options for the textfield.
Notes:
addToHEAD()
function does not need to be called.
$name
is empty or undef, but the CSS and Javascript are loaded if needed. This can be used to preload the CSS and Javascript with a parameterless %DATEPICKER{}%
variable.
Example:
use TWiki::Plugins::DatePickerPlugin; ... my $fromDate = TWiki::Plugins::DatePickerPlugin::renderForEdit( 'from', '2012-12-31'); my $toDate = TWiki::Plugins::DatePickerPlugin::renderForEdit( 'to', undef, '%Y');
TWiki::Plugins::DatePickerPlugin::addToHEAD( $setup )
This function will automatically add the headers for the calendar to the page
being rendered. It's intended for use when you want more control over the
formatting of your calendars than renderForEdit
affords. $setup
is the name
of the calendar setup module; it can either be omitted, in which case the method
described in the Mishoo documentation can be used to create calendars, or it
can be 'twiki'
, in which case a Javascript helper function called
'showCalendar' is added that simplifies using calendars to set a value in a
text field. For example, say we wanted to display the date with the calendar
icon before the text field, using the format %Y %b %e
use TWiki::Plugins::DatePickerPlugin; ... sub commonTagsHandler { .... # Add styles and javascript for the date picker & enable 'showCalendar' TWiki::Plugins::DatePickerPlugin::addToHEAD( 'twiki' ); my $cal = CGI::image_button( -name => 'img_datefield', -onclick => "return showCalendar('id_datefield','%Y %b %e')", -src=> TWiki::Func::getPubUrlPath() . '/' . TWiki::Func::getTwikiWebname() . '/DatePickerPlugin/img.gif', -alt => 'Calendar', -align => 'middle' ) . CGI::textfield( { name => 'date', id => "id_datefield" }); .... }
The first parameter to showCalendar
is the id of the textfield, and the
second parameter is the date format. Default format is '%Y-%m-%d'
.
The addToHEAD
function can be called from commonTagsHandler
for adding
the header to all pages, or from beforeEditHandler
just for edit pages etc.
You do not need to install anything on the browser to use this plugin. These instructions are for the administrator who installs the plugin on the TWiki server.
DatePickerPlugin.zip
in your twiki installation directory.
{Plugins}{DatePickerPlugin}
settings in the "Extensions" section of configure:
|
|||||||||
|
|||||||||||||||||||||||||||
Related Topics: VarDATEPICKER, TWikiPreferences, TWikiForms, TWikiPlugins
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
Microchip® and others, are registered trademarks or trademarks of Microchip Technology Inc. and its subsidiaries.
Arm® and others are registered trademarks or trademarks of Arm Limited (or its affiliates). Other terms and product names may be trademarks of others.
Ideas, requests, contributions ? Connect to LinksToCommunities page.