LSformElement :: select_list / select_box : permit to put possible values in labelled...
[ldapsaisie.git] / public_html / templates / default / LSformElement_select.tpl
index df4c4f4..0fbbbda 100644 (file)
@@ -1,8 +1,9 @@
 <ul class='LSform' id='{$attr_name}'>
 {if $freeze}
   {foreach from=$values item=value}
-    {if $possible_values.$value}
-    <li>{$possible_values.$value}</li>
+    {LSformElement_select_checkIsValidValue value=$value possible_values=$possible_values}
+    {if $LSformElement_select_isValidValue}
+    <li>{$LSformElement_select_isValidValue_label}</li>
     {else}
     <li class='LSform-errors'>{getFData format=$unrecognized_value_label_format data=$value}</li>
     {/if}
 {else}
   <li>
     <select name='{$attr_name}[]' {if $multiple}multiple{/if} class='LSformElement_select'>
-      {html_options options=$possible_values selected=$values}
+      {foreach from=$possible_values key=key item=label}
+        {if is_array($label)}
+          {if count($label.possible_values)>0}
+          <optgroup label="{$label.label}">
+            {html_options options=$label.possible_values selected=$values}
+          </optgroup>
+          {/if}
+        {else}
+          <option value="{$key}" {if in_array($key,$values)}selected{/if}>{$label}</option>
+        {/if}
+      {/foreach}
     </select>
   </li>
 {/if}