API16

Difference between revisions of "JHtml/calendar"

From Joomla! Documentation

< API16:JHtml
m (removing red link to edit, no existant pages)
m (preparing for archive only)
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
 
Displays a calendar control field
 
Displays a calendar control field
  
<span class="editsection" style="font-size:76%;">
+
 
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
  
 
<! removed transcluded page call, red link never existed >
 
<! removed transcluded page call, red link never existed >
Line 80: Line 78:
 
</source>
 
</source>
  
<span class="editsection" style="font-size:76%;">
+
 
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
 
<! removed transcluded page call, red link never existed >
 
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
<CodeExamplesForm />
+
=== Code Examples ===
 
<dpl>
 
<dpl>
 
  noresultsheader=\n
 
  noresultsheader=\n
 
  category=calendar
 
  category=calendar
 
  category=JHtml
 
  category=JHtml
  category=CodeExample
+
  namespace=CodeExample
 
  category=MethodExample
 
  category=MethodExample
 
  include=*
 
  include=*

Latest revision as of 20:44, 24 March 2017

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Displays a calendar control field


<! removed transcluded page call, red link never existed >

Syntax[edit]

static calendar($value, $name, $id, $format= '%Y-%m-%d', $attribs=null)
Parameter Name Default Value Description
$value The date value
$name The name of the text field
$id The id of the text field
$format '%Y-%m-%d' The date format
$attribs null Additional html attributes

Defined in[edit]

libraries/joomla/html/html.php

Importing[edit]

jimport( 'joomla.html.html' );

Source Body[edit]

public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null)
{
        static $done;

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

        // Load the calendar behavior
        JHtml::_('behavior.calendar');

        $readonly=isset($attribs['readonly']) && $attribs['readonly']=='readonly';
        if (is_array($attribs)) {
                $attribs = JArrayHelper::toString($attribs);
        }

        // Only display the triggers once for each control.
        if (!in_array($id, $done) && !$readonly)
        {
                $document = &JFactory::getDocument();
                $document->addScriptDeclaration('window.addEvent(\'domready\', function() {Calendar.setup({
                inputField: "'.$id.'",          // id of the input field
                ifFormat: "'.$format.'",        // format of the input field
                button: "'.$id.'_img",          // trigger for the calendar (button ID)
                align: "Tl",                            // alignment (defaults to "Bl")
                singleClick: true
        });});');
                $done[] = $id;
        }

        return '<input type="text" name="'.$name.'" id="'.$id.'" value="'.htmlspecialchars($value, ENT_COMPAT, 'UTF-8').'" '.$attribs.' />'.
                        JHTML::_('image','system/calendar.png', JText::_('calendar'), array( 'class' => 'calendar', 'id' => $id.'_img'), true);
}


<! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]