Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime Form input: minutes to seconds, 0 to 60, 0 to empty, null to true? #6518

Closed
jhawkwind opened this issue May 8, 2015 · 6 comments
Closed
Labels
Milestone

Comments

@jhawkwind
Copy link
Contributor

When you enable the Form input type DateTime, and you enable the seconds field, the minutes display 00 to 59, but the seconds display is 01 to 60. It needs to be one, or the other; though 00 makes more sense in general.

                <?= $this->Form->input('test',[
                    'type' => 'datetime',
                    'second' => null,
                    'label' => 'TEST',
                    'title' => 'This is the start time.',
                    'empty' => '-',
                    'default' => ''
                ]) ?>

0to60_minutestoseconds

Also, documentation here (http://book.cakephp.org/3.0/en/views/helpers/form.html#creating-date-and-time-inputs) says:

  • second Set to true to enable seconds drop down.

But when you attempt to do so, you get a RuntimeException that

Options for "second" must be an array|false|null

Though it seems null is the correct answer, not true? Or is this a different invocation path?

Also, with the above option, after a form submit, the minute field defaults to the empty rather than 00 field if the user select exactly 3:00:00 PM. This issue does not occur for the hour, and obviously not for the seconds, since the seconds go from 1 to 60 rather than 0 to 59.

@jhawkwind jhawkwind changed the title DateTime Form input, minutes to seconds, 0 to 60? DateTime Form input, minutes to seconds, 0 to 60, 0 to empty, null to true? May 8, 2015
@jhawkwind jhawkwind changed the title DateTime Form input, minutes to seconds, 0 to 60, 0 to empty, null to true? DateTime Form input: minutes to seconds, 0 to 60, 0 to empty, null to true? May 8, 2015
@dereuromark dereuromark added this to the 3.0.5 milestone May 8, 2015
@lorenzo
Copy link
Member

lorenzo commented May 9, 2015

Fixed in #6519

@lorenzo lorenzo closed this as completed May 9, 2015
@xavier83ar
Copy link

Although second's options have been fixed to be the same of minutes, there is still an issue with the correct value to set for the "second" option key.
Although documentation indicates that 'second' => true is required to show seconds selector, doing it ends up with a RuntimeException. I know that this could be only a documentation outdated issue, but I think that it's far more intuitive having to put 'true' instead of 'null' for showing the selector. I think that this issue should be taking into consideration.

@markstory
Copy link
Member

The following works fine for me in a cake3 app.

echo $this->Form->input('created', ['second' => []]);

Where does the documentation say second => true should work?

@jhawkwind
Copy link
Contributor Author

This was mentioned in the original issue ticket. That at the documentation here: http://book.cakephp.org/3.0/en/views/helpers/form.html#creating-date-and-time-inputs

It says:

  • second Set to true to enable seconds drop down.

@xavier83ar
Copy link

Yeah, setting 'second' => [] works, but again, I still think that having to set an option to an empty array to making it appear isn't very intuitive.
Anyway, that's my opinion and could be subject of discussion, the issue here is to have documentation fixed to be updated with how it works.

@markstory
Copy link
Member

Shouldn't be hard to make second => true work. I'll take a look.

markstory added a commit that referenced this issue Aug 3, 2015
This option should have always worked but was missing test coverage
before.

Refs #6518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants