1 <select name="recipient" class="form-control input-lg" id="recipient" required>
2 {{foreach $contacts as $contact}}
3 <option value="{{$contact.id}}"{{if $contact.id == $selected}} selected{{/if}}>{{$contact.name}}</option>
6 <script type="text/javascript">
8 let $recipient_input = $('[name="recipient"]');
10 let acl = new Bloodhound({
11 local: {{$contacts|@json_encode nofilter}},
12 identify: function(obj) { return obj.id.toString(); },
13 datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name', 'addr']),
14 queryTokenizer: Bloodhound.tokenizers.whitespace,
15 sorter: function (itemA, itemB) {
16 if (itemA.name === itemB.name) {
18 } else if (itemA.name > itemB.name) {
27 let suggestionTemplate = function (item) {
28 return '<div><img src="' + item.micro + '" alt="" style="float: left; width: auto; height: 2.8em; margin-right: 0.5em;"><p style="margin-left: 3.3em;"><strong>' + item.name + '</strong><br /><em>' + item.addr + '</em></p></div>';
31 $recipient_input.tagsinput({
32 confirmKeys: [13, 44],
34 tagClass: 'label label-info',
35 itemValue: function (item) { return item.id.toString(); },
38 itemTitle: function(item) {
45 suggestion: suggestionTemplate
47 source: acl.ttAdapter()
52 // Import existing ACL into the tags input fields.
53 $recipient_input.tagsinput('add', acl.get({{$selected}})[0]);