Actions

Difference between revisions of "Calendar form field type"

From Joomla! Documentation

(Add filter types available for calendar field)
m
Line 8: Line 8:
 
* '''name''' (mandatory) is the unique name of the field.
 
* '''name''' (mandatory) is the unique name of the field.
 
* '''label''' (mandatory) (translatable) is the descriptive title of the field.
 
* '''label''' (mandatory) (translatable) is the descriptive title of the field.
* '''default''' (optional) is the default date.  This must be given in the same format as specified by the format argument.
+
* '''default''' (optional) is the default date.  This must be given in the same format as specified by the format argument. You can put "NOW" to have current time.
 
* '''description''' (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the text box.
 
* '''description''' (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the text box.
 
* '''readonly''' (optional) is whether the text box is read-only (''true'' or ''false''). If the text box is read-only, the date cannot be changed, but can be selected and copied. No calendar icon will be shown.
 
* '''readonly''' (optional) is whether the text box is read-only (''true'' or ''false''). If the text box is read-only, the date cannot be changed, but can be selected and copied. No calendar icon will be shown.

Revision as of 11:14, 26 September 2012

Params.calendar.jpg

The calendar form field type provides a text box for entry of a date. An icon next to the text box provides a link to a pop-up calendar, which can also be used to enter the date value. If the field has a saved value this is shown in the text box. Otherwise the default value, if any, is displayed.

  • type (mandatory) must be calendar.
  • name (mandatory) is the unique name of the field.
  • label (mandatory) (translatable) is the descriptive title of the field.
  • default (optional) is the default date. This must be given in the same format as specified by the format argument. You can put "NOW" to have current time.
  • description (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the text box.
  • readonly (optional) is whether the text box is read-only (true or false). If the text box is read-only, the date cannot be changed, but can be selected and copied. No calendar icon will be shown.
  • disabled (optional) is whether the text box is disabled (true or false). If the text box is disabled, the date cannot be changed, selected or copied.
  • class (optional) is a CSS class name for the HTML form field.
  • format (optional) is the date format to be used. This is in the format used by PHP to specify date string formats (see below). If no format argument is given, '%Y-%m-%d' is assumed (giving dates like '2008-04-16').
  • filter (optional) is time zone to be used. There are two values; server_utc and user_utc. The first one is server time zone and the later is user time zone as configured in global configuration and user information respectively.

Example XML field definition:

<field name="mycalendar" type="calendar" default="5-10-2008" label="Select a date" description="" format="%d-%m-%Y" />

The format attribute specifies the format that the date string will be saved in. It is also the format that manually entered dates need to be enterered in; except that the punctuation character is ignored. The coding scheme used to specify date formats is the same as the PHP date string format, full details of which can be found on http://www.php.net/manual/en/function.date.php. The following are some of the most frequently used date string codes:

Character Description Example
d Day of the month, 2 digits with leading zeros 01 to 31
D A textual representation of a day, three letters Mon through Sun
j Day of the month without leading zeros 1 to 31
l A full textual representation of the day of the week Monday through Sunday
N ISO-8601 numeric representation of the day of the week (only supported on servers running PHP 5.1.0 or later) 1 (for Monday) through 7 (for Sunday)
S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j
w Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
z The day of the year (starting from 0) 0 through 365
W ISO-8601 week number of year, weeks starting on Monday 42 (42nd week in the year)
F A full textual representation of a month January through December
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
t Number of days in the given month 28 through 31
o ISO-8601 year number. Same value as Y except that if the ISO week number (W) belongs to the previous or next year, that year is used instead (only supported on servers running PHP 5.1.0 or later) 1999 or 2003
Y A full numeric representation of a year, 4 digits 1999 or 2003
y A two-digit representation of a year 99 or 03
a Lowercase Ante Meridiem or Post Meridiem am or pm
A Uppercase Ante Meridiem or Post Meridiem AM or PM

Note: The format in which dates are stored in the params.ini file is that specified by the format argument. Since there can be language-dependent elements to this format (for example, the '%F' specifier), you need to be careful not to use such elements if there is a possibility that the front-end and back-end languages may be different.

Note: The calendar form field type does not support non-Gregorian calendars. If you need to support non-Gregorian calendars then you will need to create a custom form field type to support your calendar.

See also