cvs: smarty / NEWS /libs/plugins function.html_radios.php

"Monte Ohrt" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmohrt1115389639@cvsserver>
mohrt		Fri May  6 10:27:19 2005 EDT

  Modified files:              
    /smarty	NEWS 
    /smarty/libs/plugins	function.html_radios.php 
  Log:
  make form input label ids optional (monte)
  
  
http://cvs.php.net/diff.php/smarty/NEWS?r1=1.501&r2=1.502&ty=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.501 smarty/NEWS:1.502
--- smarty/NEWS:1.501	Mon May  2 10:03:17 2005
+++ smarty/NEWS	Fri May  6 10:27:19 2005
@@ -1,3 +1,4 @@
+  - make form input label ids optional (monte)
   - add error message for empty if/elseif statements (eykanal,
     monte)
   - cast selected value to string for comparison in html_radios
http://cvs.php.net/diff.php/smarty/libs/plugins/function.html_radios.php?r1=1.26&r2=1.27&ty=u
Index: smarty/libs/plugins/function.html_radios.php
diff -u smarty/libs/plugins/function.html_radios.php:1.26 smarty/libs/plugins/function.html_radios.php:1.27
--- smarty/libs/plugins/function.html_radios.php:1.26	Fri Apr 15 12:32:30 2005
+++ smarty/libs/plugins/function.html_radios.php	Fri May  6 10:27:19 2005
@@ -48,6 +48,7 @@
     $selected = null;
     $separator = '';
     $labels = true;
+    $label_ids = false;
     $output = null;
     $extra = '';
 
@@ -68,6 +69,7 @@
                 break;
 
             case 'labels':
+            case 'label_ids':
                 $$_key = (bool)$_val;
                 break;
 
@@ -106,13 +108,13 @@
     if (isset($options)) {
 
         foreach ($options as $_key=>$_val)
-            $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
+            $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
 
     } else {
 
         foreach ($values as $_i=>$_key) {
             $_val = isset($output[$_i]) ? $output[$_i] : '';
-            $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
+            $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
         }
 
     }
@@ -125,17 +127,21 @@
 
 }
 
-function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) {
+function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) {
     $_output = '';
     if ($labels) {
-      $_id = smarty_function_escape_special_chars($name . '_' . $value);
-      $_output .= '<label for="' . $_id . '">';
+      if($label_ids) {
+          $_id = smarty_function_escape_special_chars(str_replace(' ', '_', $name . '_' . $value));
+          $_output .= '<label for="' . $_id . '">';
+      } else {
+          $_output .= '<label>';           
+      }
    }
    $_output .= '<input type="radio" name="'
         . smarty_function_escape_special_chars($name) . '" value="'
         . smarty_function_escape_special_chars($value) . '"';
 
-   if ($labels) $_output .= ' id="' . $_id . '"';
+   if ($labels && $label_ids) $_output .= ' id="' . $_id . '"';
 
     if ((string)$value==$selected) {
         $_output .= ' checked="checked"';

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.