Although I can think of no real reason to have a seconds selection, except for maybe putting in a speed record :)
... Your quickest solution is: First copy your cake/lib/view/helpers/html.php file to your app/view/ helpers/ directory. This allows you to override the default functionality provided with the basic cake install Next, edit/modify your file app/view/helpers/html.php Add the following function to the class deffiniton: -------------------------------------------------------------------------------- /** * Returns a SELECT element for seconds. * * @param string $tagName Prefix name for the SELECT element * @param string $selected Option which is selected. * @param array $optionAttr Attribute array for the option elements. * @return mixed * @access public */ function secondOptionTag($tagName, $selected =null, $selectAttr = null, $optionAttr = null, $showEmpty = true) { if (empty($selected) && ($this->tagValue($tagName))) { $selected = date('s', strtotime($this- >tagValue($tagName))); } $secValue = empty($selected) ? ($showEmpty ? NULL : date('s')) : $selected; for ($secCount = 0; $secCount < 60; $secCount++) { $secs[sprintf('%02d', $secCount)] = sprintf('%02d', $secCount); } $option = $this->selectTag($tagName . "_sec", $secs, $secValue, $selectAttr, $optionAttr, $showEmpty); return $option; } -------------------------------------------------------------------------------- You can then add the following to your views: -------------------------------------------------------------------------------- <?PHP echo $html->secondOptionTag('speed'); ?> -------------------------------------------------------------------------------- The problem with this is that you have to remember to update your html.php when if you change your cake version. A better longer term solution is: Create the file 'show_seconds.php' in your app/view/helpers/ directory. -------------------------------------------------------------------------------- /** * helper seconds to give kionae a seconds select. */ if (!defined('SHOW_SECONDS_DEFFINITION')) { define('SHOW_SECONDS_DEFFINITION', 1); class ShowSecondsHelper extends Helper { var $helpers = array('Html'); /** * Returns a SELECT element for seconds. * * @param string $tagName Prefix name for the SELECT element * @param string $selected Option which is selected. * @param array $optionAttr Attribute array for the option elements. * @return mixed * @access public */ function select($tagName, $selected =null, $selectAttr = null, $optionAttr = null, $showEmpty = true) { if (empty($selected) && ($this->tagValue($tagName))) { $selected = date('s', strtotime($this- >tagValue($tagName))); } $secValue = empty($selected) ? ($showEmpty ? NULL : date('s')) : $selected; for ($secCount = 0; $secCount < 60; $secCount++) { $secs[sprintf('%02d', $secCount)] = sprintf('%02d', $secCount); } $option = $this->Html->selectTag($tagName . "_sec", $secs, $secValue, $selectAttr, $optionAttr, $showEmpty); return $option; } } } -------------------------------------------------------------------------------- Include this in your controler's $helpers array as in: -------------------------------------------------------------------------------- class MyControler extends AppController { var $helpers = ('ShowSeconds', 'Html', ... ); ... } -------------------------------------------------------------------------------- Invoke in your views with this: -------------------------------------------------------------------------------- <?PHP echo $showSeconds->tag('speed'); ?> -------------------------------------------------------------------------------- Jeff On Sep 24, 12:41 pm, kionae <[EMAIL PROTECTED]> wrote: > Is there a way to get dateTime to display a dropdown for seconds? All > I can get is hours and minutes. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---