|
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 |
Is this MUST HAVE or Do-It-Yourself stuff? |
Must have! |
|
72% |
[ 8 ] |
Do-It-Yourself! |
|
27% |
[ 3 ] |
|
Total Votes : 11 |
|
Author |
Message |
tpanula Smarty Rookie
Joined: 19 May 2003 Posts: 6
|
Posted: Mon May 19, 2003 9:04 am Post subject: html_select_date needs a NULL option |
|
|
html_select_date needs a NULL option
I'd like to have one extra option that says; no value selected.
For example, I usually give an option to remove the article from the website at a given date. The client can fill it or leave it out to NULL.
Currently there is no option available to make it possible. See below; the stuff in italics is what I want.
<select name="day">
<option value="NULL">Choose your optional day of month</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
...
</select>
<select name="month">
<option value="NULL">Choose your optional month of year</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
...
</select>
<select name="year"
<option value="NULL">Choose your optional year</option>
<option value="1">2001</option>
<option value="2">2002</option>
<option value="3">2003</option>
...
</select>
I think this would be a useful feature addition. |
|
Back to top |
|
moenm Smarty Rookie
Joined: 24 Jun 2003 Posts: 5
|
Posted: Tue Jun 24, 2003 1:42 am Post subject: Here... |
|
|
Take the below text and create a new text file with the contents. For the easiest useage create the new file in your smarty/plugins directory.
from your plugins directory, execute
patch < name_of_the_file_you_created
useage {html_select_date not_selected="true"}
Tested with PHP 4.3.2, your mileage may vary
Have fun. Hopefully they will add this in.
Code: |
*** function.html_select_date.php Mon Jun 23 18:21:03 2003
--- function.html_select_date_tweaked.php Mon Jun 23 18:23:33 2003
*************** function smarty_function_html_select_dat
*** 61,66 ****
--- 61,68 ----
/* String printed between the different fields. */
$field_separator = "\n";
$time = time();
+ # moenm 2003-06-23 Should the current date be selected by default
+ $not_selected = false;
extract($params);
*************** function smarty_function_html_select_dat
*** 123,129 ****
$month_result .= smarty_function_html_options(array('output' => $month_names,
'values' => $month_values,
! 'selected' => $month_values[$time[1]-1],
'print_result' => false),
$smarty);
--- 125,131 ----
$month_result .= smarty_function_html_options(array('output' => $month_names,
'values' => $month_values,
! 'selected' => $not_selected ? '' : $month_values[$time[1]-1],
'print_result' => false),
$smarty);
*************** function smarty_function_html_select_dat
*** 155,161 ****
$day_result .= '>'."\n";
$day_result .= smarty_function_html_options(array('output' => $days,
'values' => $day_values,
! 'selected' => $time[2],
'print_result' => false),
$smarty);
$day_result .= '</select>';
--- 157,163 ----
$day_result .= '>'."\n";
$day_result .= smarty_function_html_options(array('output' => $days,
'values' => $day_values,
! 'selected' => $not_selected ? '' : $time[2],
'print_result' => false),
$smarty);
$day_result .= '</select>';
*************** function smarty_function_html_select_dat
*** 195,201 ****
$year_result .= '>'."\n";
$year_result .= smarty_function_html_options(array('output' => $years,
'values' => $years,
! 'selected' => $time[0],
'print_result' => false),
$smarty);
$year_result .= '</select>';
--- 197,203 ----
$year_result .= '>'."\n";
$year_result .= smarty_function_html_options(array('output' => $years,
'values' => $years,
! 'selected' => $not_selected ? '' : $time[0],
'print_result' => false),
$smarty);
$year_result .= '</select>';
| [/code] |
|
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
|