select2.tpl 1.3 KB

1234567891011121314151617181920212223242526272829
  1. {if $enableLabel}
  2. <label for="{$addIDs}_{$name}" class="col-sm-3 control-label">{$MGLANG->T('label')}</label>
  3. {/if}
  4. <div class="col-sm-{$colWidth}">
  5. <select {if $multiple}multiple="multiple"{/if} id="{$addIDs}_{$name}" name="{$nameAttr}{if $multiple}[]{/if}" {if $readonly||$disabled}disabled="disabled"{/if} {foreach from=$dataAttr key=dataKey item=dataValue}data-{$dataKey}="{$dataValue}"{/foreach}>
  6. {foreach from=$options item=option key=opValue}
  7. <option value="{$opValue}" {if $multiple}{if in_array($opValue,$value)}selected{/if}{else}{if $opValue==$value}selected{/if}{/if}>
  8. {$option}
  9. </option>
  10. {/foreach}
  11. </select>
  12. {if $readonly}
  13. <input type="hidden" name="{$nameAttr}" value="{$value}" />
  14. {/if}
  15. {if $enableDescription}
  16. <span class="help-block">{$MGLANG->T('description')}</span>
  17. {/if}
  18. <span class="help-block error-block"{if !$error}style="display:none;"{/if}>{$error}</span>
  19. {literal}
  20. <script data-cfasync="false" type="text/javascript">
  21. $(document).ready(function(){
  22. $("#{/literal}{$addIDs}_{$name}{literal}").select2({
  23. containerCssClass: ' tpx-select2-container select2-grey',
  24. dropdownCssClass: ' tpx-select2-drop'
  25. });
  26. });
  27. </script>
  28. {/literal}
  29. </div>