Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

html_select_date - month_names bug

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
szen
Smarty Rookie


Joined: 23 Dec 2003
Posts: 17

PostPosted: Tue Jun 26, 2012 9:44 pm    Post subject: html_select_date - month_names bug Reply with quote

I think there is bug in month_names parameter. There should be 12 index array. And i did put 12 month names. But the first one is being cut off, and last one is empty.

Original code:

Code:

for ($i = 1; $i <= 12; $i++) {
            $_val = sprintf('%02d', $i+1);
            $_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[$i]) : ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[$i]));
            $_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[$i]);
            $_html_months .= '<option value="' . $_value . '"'
                . ($_val == $_month ? ' selected="selected"' : '')
                . '>' . $_text . '</option>' . $option_separator;
        }



Code after my changes

Code:
for ($i = 0; $i <= 11; $i++) {
            $_val = sprintf('%02d', ($i+1));
            $_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[$i]) : ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[$i]));
            $_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[$i]);
            $_html_months .= '<option value="' . $_value . '"'
                . ($_val == $_month ? ' selected="selected"' : '')
                . '>' . $_text . '</option>' . $option_separator;
        }


Might not be proper way but did work for now
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Tue Jun 26, 2012 9:56 pm    Post subject: Reply with quote

Which version is that "original code" from? http://code.google.com/p/smarty-php/source/browse/trunk/distribution/libs/plugins/function.html_select_date.php#305 looks different.
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


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

PostPosted: Tue Jun 26, 2012 10:34 pm    Post subject: Reply with quote

See in the documentation www.smarty.net/docs/en/language.function.html.select.date.tpl

The month_names parameter must be an array with index 1 to 12.

You did pass an array with index 0 to 11.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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