select list/box: display values respecting possible values order

This commit is contained in:
Benjamin Renard 2022-12-05 11:37:17 +01:00
parent fd17f87a57
commit a9d00cd3c1
2 changed files with 32 additions and 6 deletions

View file

@ -1,10 +1,23 @@
<ul class='LSform' id='{$attr_name|escape:"htmlall"}'>
{if $freeze}
{foreach from=$possible_values item=label key=value name=LSformElement_selectbox}
{if is_array($label)}
{if count($label.possible_values)>0}
{foreach from=$label.possible_values item=l key=v name=LSformElement_selectbox_sub_values}
{if in_array($v, $values)}
<li>{$l|escape:"htmlall"}</li>
{/if}
{/foreach}
{/if}
{else}
{if in_array($value, $values)}
<li>{$label|escape:"htmlall"}</li>
{/if}
{/if}
{/foreach}
{foreach from=$values item=value}
{LSformElement_select_checkIsValidValue value=$value possible_values=$possible_values}
{if $LSformElement_select_isValidValue}
<li>{$LSformElement_select_isValidValue_label|escape:"htmlall"}</li>
{else}
{if !$LSformElement_select_isValidValue}
<li class='LSform-errors'>{getFData format=$unrecognized_value_label_format data=$value}</li>
{/if}
{foreachelse}

View file

@ -1,10 +1,23 @@
<ul class='LSform{if $inline} LSformElement_select_box_inline{/if}' id='{$attr_name|escape:"htmlall"}'>
{if $freeze}
{foreach from=$possible_values item=label key=value name=LSformElement_selectbox}
{if is_array($label)}
{if count($label.possible_values)>0}
{foreach from=$label.possible_values item=l key=v name=LSformElement_selectbox_sub_values}
{if in_array($v, $values)}
<li>{$l|escape:"htmlall"}</li>
{/if}
{/foreach}
{/if}
{else}
{if in_array($value, $values)}
<li>{$label|escape:"htmlall"}</li>
{/if}
{/if}
{/foreach}
{foreach from=$values item=value}
{LSformElement_select_checkIsValidValue value=$value possible_values=$possible_values}
{if $LSformElement_select_isValidValue}
<li>{$LSformElement_select_isValidValue_label|escape:"htmlall"}</li>
{else}
{if !$LSformElement_select_isValidValue}
<li class='LSform-errors'>{getFData format=$unrecognized_value_label_format data=$value}</li>
{/if}
{foreachelse}