|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
cybot Smarty Regular
Joined: 20 Apr 2005 Posts: 83
|
Posted: Mon Jun 11, 2007 2:33 pm Post subject: [patch] suffix for html_select_date/time |
|
|
i created a patch for allowing specifying suffix additional to prefix
Code: | {html_select_date
prefix='object[date]['
suffix='][]'
} |
it allows for example
Code: | <select name="object[date][Day][]">...
<select name="object[date][Month][]">...
<select name="object[date][Year][]">...
|
Patch:
Code: | Index: libs/plugins/function.html_select_date.php
===================================================================
RCS file: /repository/smarty/libs/plugins/function.html_select_date.php,v
retrieving revision 1.36
diff -u -r1.36 function.html_select_date.php
--- libs/plugins/function.html_select_date.php 6 Mar 2007 20:13:55 -0000 1.36
+++ libs/plugins/function.html_select_date.php 11 Jun 2007 14:03:28 -0000
@@ -42,6 +42,7 @@
require_once $smarty->_get_plugin_filepath('function','html_options');
/* Default values. */
$prefix = "Date_";
+ $suffix = "";
$start_year = strftime("%Y");
$end_year = $start_year;
$display_days = true;
@@ -87,6 +88,7 @@
foreach ($params as $_key=>$_value) {
switch ($_key) {
case 'prefix':
+ case 'suffix':
case 'time':
case 'start_year':
case 'end_year':
@@ -194,9 +196,9 @@
$month_result .= '<select name=';
if (null !== $field_array){
- $month_result .= '"' . $field_array . '[' . $prefix . 'Month]"';
+ $month_result .= '"' . $field_array . '[' . $prefix . 'Month' . $suffix . ']"';
} else {
- $month_result .= '"' . $prefix . 'Month"';
+ $month_result .= '"' . $prefix . 'Month' . $suffix . '"';
}
if (null !== $month_size){
$month_result .= ' size="' . $month_size . '"';
@@ -231,9 +233,9 @@
$day_result .= '<select name=';
if (null !== $field_array){
- $day_result .= '"' . $field_array . '[' . $prefix . 'Day]"';
+ $day_result .= '"' . $field_array . '[' . $prefix . 'Day' . $suffix . ']"';
} else {
- $day_result .= '"' . $prefix . 'Day"';
+ $day_result .= '"' . $prefix . 'Day' . $suffix . '"';
}
if (null !== $day_size){
$day_result .= ' size="' . $day_size . '"';
@@ -257,9 +259,9 @@
if ($display_years) {
$field_separator_count++;
if (null !== $field_array){
- $year_name = $field_array . '[' . $prefix . 'Year]';
+ $year_name = $field_array . '[' . $prefix . 'Year' . $suffix . ']';
} else {
- $year_name = $prefix . 'Year';
+ $year_name = $prefix . 'Year' . $suffix;
}
if ($year_as_text) {
$year_result .= '<input type="text" name="' . $year_name . '" value="' . $time[0] . '" size="4" maxlength="4"';
Index: libs/plugins/function.html_select_time.php
===================================================================
RCS file: /repository/smarty/libs/plugins/function.html_select_time.php,v
retrieving revision 1.14
diff -u -r1.14 function.html_select_time.php
--- libs/plugins/function.html_select_time.php 11 Oct 2005 16:22:56 -0000 1.14
+++ libs/plugins/function.html_select_time.php 11 Jun 2007 14:05:24 -0000
@@ -27,6 +27,7 @@
require_once $smarty->_get_plugin_filepath('function','html_options');
/* Default values. */
$prefix = "Time_";
+ $suffix = "";
$time = time();
$display_hours = true;
$display_minutes = true;
@@ -49,6 +50,7 @@
foreach ($params as $_key=>$_value) {
switch ($_key) {
case 'prefix':
+ case 'suffix':
case 'time':
case 'field_array':
case 'all_extra':
@@ -88,9 +90,9 @@
$hours[$i] = sprintf('%02d', $hours[$i]);
$html_result .= '<select name=';
if (null !== $field_array) {
- $html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Hour' . $suffix . ']"';
} else {
- $html_result .= '"' . $prefix . 'Hour"';
+ $html_result .= '"' . $prefix . 'Hour' . $suffix . '"';
}
if (null !== $hour_extra){
$html_result .= ' ' . $hour_extra;
@@ -114,9 +116,9 @@
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
$html_result .= '<select name=';
if (null !== $field_array) {
- $html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"';
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Minute' . $suffix . ']"';
} else {
- $html_result .= '"' . $prefix . 'Minute"';
+ $html_result .= '"' . $prefix . 'Minute' . $suffix . '"';
}
if (null !== $minute_extra){
$html_result .= ' ' . $minute_extra;
@@ -141,9 +143,9 @@
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
$html_result .= '<select name=';
if (null !== $field_array) {
- $html_result .= '"' . $field_array . '[' . $prefix . 'Second]"';
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Second' . $suffix . ']"';
} else {
- $html_result .= '"' . $prefix . 'Second"';
+ $html_result .= '"' . $prefix . 'Second' . $suffix . '"';
}
if (null !== $second_extra){
@@ -165,9 +167,9 @@
if ($display_meridian && !$use_24_hours) {
$html_result .= '<select name=';
if (null !== $field_array) {
- $html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"';
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Meridian' . $suffix . ']"';
} else {
- $html_result .= '"' . $prefix . 'Meridian"';
+ $html_result .= '"' . $prefix . 'Meridian' . $suffix . '"';
}
if (null !== $meridian_extra){
|
Last edited by cybot on Mon Jun 11, 2007 2:35 pm; edited 1 time in total |
|
Back to top |
|
cybot Smarty Regular
Joined: 20 Apr 2005 Posts: 83
|
Posted: Mon Jun 11, 2007 2:35 pm Post subject: |
|
|
additionally, would a patch allowing to specify specific name for every selectbox accepted? |
|
Back to top |
|
|
|
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
|