Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
html_select_time Meridian Default Error

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
Metzen
Smarty Rookie


Joined: 16 Jan 2004
Posts: 6

PostPosted: Thu Sep 12, 2013 5:40 pm    Post subject: html_select_time Meridian Default Error Reply with quote

html_select_time has a defaulting error for the Meridian dropdown. This is confirmed in the latest release (Smarty 3.1.14).

Smarty code:
{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}

$selectedTime is an empty variable (but would have Hour, Minute, and Meridian keys if there was a selected time).

Generated HTML (just the Meridian select):
<select name="pt[Meridian]">
<option value="">-AM/PM-</option>
<option value="am" selected="selected">AM</option>
<option value="pm">PM</option>
</select>

Expected HTML (just the Meridian select):
<select name="pt[Meridian]">
<option value="">-AM/PM-</option>
<option value="am">AM</option>
<option value="pm">PM</option>
</select>

Or the first option could be:
<option value="" selected="selected">-AM/PM-</option>

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>';
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4631
Location: Hamburg / Germany

PostPosted: Fri Sep 13, 2013 8:49 pm    Post subject: Reply with quote

The fix is now in the SVN trunk and will be later included in 3.1.15
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP