Update: for consecutive increasing (no reset each hour) see this post: viewtopic.php?f=8&t=11424
A known way to create dropdown for time selection is to type in manually editable's opt_values as in following (non-optimal) example.
What if we need 5 minutes step? It could become a very sad experience.. Not to mention if step is 3,2,1 minutes
We definitely can have a helper.
An dropdown definition becomes as follows:
A known way to create dropdown for time selection is to type in manually editable's opt_values as in following (non-optimal) example.
- Code: Select all
<cms:editable name="start_time" label="Time From (24 Hrs)"
opt_values=' Unspecified |
00:00 | 00:30 | 01:00 | 01:30 | 02:00 | 02:30 | 03:00 | 03:30 |
04:00 | 04:30 | 05:00 | 05:30 | 06:00 | 06:30 | 07:00 | 07:30 |
08:00 | 08:30 | 09:00 | 09:30 | 10:00 | 10:30 | 11:00 | 11:30 |
12:00 | 12:30 | 13:00 | 13:30 | 14:00 | 14:30 | 15:00 | 15:30 |
16:00 | 16:30 | 17:00 | 17:30 | 18:00 | 18:30 | 19:00 | 19:30 |
20:00 | 20:30 | 21:00 | 21:30 | 22:00 | 22:30 | 23:00 | 23:30 |'
type='dropdown'
/>
What if we need 5 minutes step? It could become a very sad experience.. Not to mention if step is 3,2,1 minutes
We definitely can have a helper.
- Code: Select all
Minutes reset every hour no matter what.
Prints timetable suitable for time-selection dropdown
<cms:call 'time_options' minute_steps='45' from='12' to='15' sep='|' />
=> 12:00 | 12:45 | 13:00 | 13:45 | 14:00 | 14:45 | 15:00 | 15:45
Get it as json => ["12:00","12:45","13:00","13:45","14:00","14:45","15:00","15:45"]
<cms:call 'time_options' minute_steps='45' from='12' to='15' as_json='1' />
An dropdown definition becomes as follows:
- Code: Select all
<cms:embed 'functions/date-time/time_options.func' />
<cms:editable name="start_time" label="Time From (24 Hrs)"
opt_values=" Unspecified | <cms:call 'time_options' minute_steps='30' />"
type='dropdown'
/>