date and time picker

samoht 13 May, 2009
Hello guy's,

I wondered if there is a way to get the date and time picker to actually pick the time as well as the date?
Do I have to modify the calendar.js if I want the user to be able to pick the date and the time?

Thanks,
GreyHead 13 May, 2009
Hi samoht,

If you look at the Dates and Time tab for the Watchman plugin configuration you will see that the top date picker has time enabled (it's not very pretty but it is functional). Also further down there are a couple of rather neat time-spinners.

Bob

PS I see the secodn date picker doesn't set the time and it should :-( I'll fix that.
samoht 13 May, 2009
Bob,
perhaps I am misunderstanding but I meant for the front end not the back end. When the user picks a date I want them to be able to pick a time as well. Currently a calendar just comes up.
GreyHead 13 May, 2009
Hi samoht,

Sure but if you look in the Watchman file you'll find the code used to create those - copy and pste it into your form code.

Bob
samoht 13 May, 2009
OK,

I looked at the cf_watchman.php file and found:

<?php
    echo $pane->endPanel();
    echo $pane->startPanel( 'Dates and Times', 'date_time' );
?>
    <table border="0" cellpadding="3" cellspacing="0" style='width:400px;'>
        <tr>
            <td colspan='4' class='cf_header' >Watch opening and closing dates</td>
        </tr>
        <tr style="background-color: #c9c9c9">
<?php
        $tooltip = "Select the date when the form opens. Leave blank for always open";
        $config = array('showsTime' => "true");
        echo $helper->createDateTD(
        	'Open date and time', 'params[open]',
            $params->get('open'), '', $tooltip, '', '', $config );
        ?>
        </tr>
        <tr style="background-color: #c9c9c9">


which refers to the helper file for the function
that looks like:
    function createDateTD($title, $name, $selected='',
        $attributes='', $tooltip='', $id=false, $translate=false, $config=null )
    {
        $id = self::createId($name, $id);
        $return  = self::createTitleTD($title, $tooltip);
        $return .= "<td>".self::calendar($selected, $name,
        $name, '%d-%m-%Y %H:%M', 'style="width:120px;"', $config )."</td>";
        return $return;
    }

    /**
     * Create a 4x<td> row with tooltip, empty td, title & Time picker
     *
     * @param $title string title
     * @param $name string field name
     * @param $selected string field value as hh:mm
     * @param $attributes string additional input attributes
     * @param $tooltip string tooltip
     * @param $id string
     *
     */
    function createTimeTD($title, $name, $selected='',
        $attributes='', $tooltip='', $id='' )
    {
        $id = self::createId($name, $id);
        $return  = self::createTitleTD($title, $tooltip);
        $return .= "<td><input type='text' name='$name' id='$id' size='10'
                	value='' $attributes /></td>";
        $start = 0;
        if ( $selected ) {
            $time_array = explode(':', $selected);
            $start = $time_array[0] * 60 + $time_array[1];
        }
        $script = "
            window.addEvent('domready', function() {
                var spinner1 = new TimeSpinner($('$id'), {
                    increment: 5,
                    delay: 150
                },
                $start );
            });
            ";
        $doc =& JFactory::getDocument();
        $doc->addScriptDeclaration($script);
        return $return;
    }


while this is my very simple form code:
<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label" style="width: 150px;">start time:</label>
    <input class="cf_datetime" title="" size="20" id="date_0" name="date_0" type="text" />
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label" style="width: 150px;">end time:</label>
    <input class="cf_datetime" title="" size="20" id="date_1" name="date_1" type="text" />
    
  </div>
  <div class="cfclear"> </div>
</div>


So I am not sure which part to include and if I need to call the helper as well or copy the functions from there?
This topic is locked and no more replies can be posted.