Jeff-Lewis / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

html_select_time Meridian Default Error #153

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. {html_select_time field_array='pt' prefix='' use_24_hours=false 
display_seconds=false hour_empty='-Hour-' minute_empty='-Minute-' 
meridian_empty='-AM/PM-' time=$selectedTime} 
2. $selectedTime is an empty variable (but would have Hour, Minute, and 
Meridian keys if there was a selected time). 

What is the expected output?
There shouldn't be a selected value since its passed an empty variable / array.
<select name="pt[Meridian]">
<option value="">-AM/PM-</option>
<option value="am">AM</option>
<option value="pm">PM</option>
</select> 

What do you see instead?
The AM is incorrectly marked as selected, which after posting confuses the hour 
and minute fields (which were left empty, but after the post have values in 
them).

<select name="pt[Meridian]">
<option value="">-AM/PM-</option>
<option value="am" selected="selected">AM</option>
<option value="pm">PM</option>
</select> 

What version of the product are you using? On what operating system?
Smarty 3.1.14 on CentOS 6.4 with PHP 5.3.3.

Please provide any additional information below.
I think the fix can be as simple as adding "$_hour > 0 && " to line 348:
$_html_meridian .= '<option value="am"'. ($_hour > 0 && $_hour < 12 ? ' 
selected="selected"' : '') .'>AM</option>' . $option_separator
. '<option value="pm"'. ($_hour < 12 ? '' : ' selected="selected"') 
.'>PM</option>' . $option_separator
. '</select>';

Original issue reported on code.google.com by gzmarket...@gmail.com on 12 Sep 2013 at 5:53

GoogleCodeExporter commented 9 years ago
The fix is already in the SVN trunk and will later be included in 3.1.15
See also forum topic 24549

Original comment by Uwe.Tews@googlemail.com on 14 Sep 2013 at 3:45