Re: form helper dateTime

2007-09-24 Thread [EMAIL PROTECTED]

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:


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:

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
-~--~~~~--~~--~--~---



form helper dateTime

2007-09-24 Thread kionae

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
-~--~~~~--~~--~--~---



Re: form helper dateTime (cake 1.2)

2007-07-20 Thread Phurter

http://www.nabble.com/form-helper-dateTime-(cake-1.2)-t4070834.html

On Jul 12, 5:00 pm, pete <[EMAIL PROTECTED]> wrote:
> hi,
> is there a way to set the minYear, maxYear for dateTime?
>
> dateTime('dateTime','DMY',24,null,null); ?>
>
> i want to reduce the number of years within the form
>
> thanks
>
> pete


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: form helper dateTime (cake 1.2)

2007-07-12 Thread kionae

Yep.

datetime('datetime', 'DMY', 24, null,
array('maxYear' => '2008', 'minYear' => '2000'), true); ?>



On Jul 12, 4:00 pm, pete <[EMAIL PROTECTED]> wrote:
> hi,
> is there a way to set the minYear, maxYear for dateTime?
>
> dateTime('dateTime','DMY',24,null,null); ?>
>
> i want to reduce the number of years within the form
>
> thanks
>
> pete


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



form helper dateTime (cake 1.2)

2007-07-12 Thread pete

hi,
is there a way to set the minYear, maxYear for dateTime?

dateTime('dateTime','DMY',24,null,null); ?>

i want to reduce the number of years within the form

thanks

pete


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---