1 <select name="recipient" class="form-control input-lg" id="recipient" required>
3 {{foreach $contacts as $contact}}
4 <option value="{{$contact.id}}"{{if $contact.id == $selected}} selected{{/if}}>{{$contact.name}}</option>
7 <script type="text/javascript">
9 let $recipient_input = $('[name="recipient"]');
11 let acl = new Bloodhound({
12 local: {{$contacts_json nofilter}},
13 identify: function(obj) { return obj.id.toString(); },
14 datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name', 'addr']),
15 queryTokenizer: Bloodhound.tokenizers.whitespace,
16 sorter: function (itemA, itemB) {
17 if (itemA.name === itemB.name) {
19 } else if (itemA.name > itemB.name) {
28 let suggestionTemplate = function (item) {
29 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>';
32 $recipient_input.tagsinput({
33 confirmKeys: [13, 44],
35 tagClass: 'label label-info',
36 itemValue: function (item) { return item.id.toString(); },
39 itemTitle: function(item) {
46 suggestion: suggestionTemplate
48 source: acl.ttAdapter()
53 // Import existing ACL into the tags input fields.
54 $recipient_input.tagsinput('add', acl.get({{$selected}})[0]);