{"action":"closed","issue":{"url":"https://api.github.com/repos/select2/select2/issues/3863","labels_url":"https://api.github.com/repos/select2/select2/issues/3863/labels{/name}","comments_url":"https://api.github.com/repos/select2/select2/issues/3863/comments","events_url":"https://api.github.com/repos/select2/select2/issues/3863/events","html_url":"https://github.com/select2/select2/issues/3863","id":112845497,"number":3863,"title":"Default value with no results message","user":{"login":"morrow95","id":626244,"avatar_url":"https://avatars.githubusercontent.com/u/626244?v=3","gravatar_id":"","url":"https://api.github.com/users/morrow95","html_url":"https://github.com/morrow95","followers_url":"https://api.github.com/users/morrow95/followers","following_url":"https://api.github.com/users/morrow95/following{/other_user}","gists_url":"https://api.github.com/users/morrow95/gists{/gist_id}","starred_url":"https://api.github.com/users/morrow95/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morrow95/subscriptions","organizations_url":"https://api.github.com/users/morrow95/orgs","repos_url":"https://api.github.com/users/morrow95/repos","events_url":"https://api.github.com/users/morrow95/events{/privacy}","received_events_url":"https://api.github.com/users/morrow95/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-22T16:51:32Z","updated_at":"2015-10-27T14:43:02Z","closed_at":"2015-10-27T14:43:02Z","body":"Using remote data... when there are no results returned I am showing a message saying so using an id=0.  In the actual select I am listing my default value and in the js I specify that default value as the placeholder.\r\n\r\nThe issue.  When searching and no results are found the 'no result' message is shown from my remote data as it should, BUT, if the user clicks this result it removes the value for the select.\r\n\r\nhtml with value/name of stephen.exe : \r\n```\r\n<select id=\"vedit-filter\" name=\"settings[filter]\" class=\"form-control\">\r\n\t<option value=\"stephen.exe\" selected=\"\">stephen.exe</option>\r\n</select>\r\n<input id=\"filter_default\" type=\"hidden\" name=\"settings[original]\" value=\"stephen.exe\"/>\r\n```\r\n\r\njs : \r\n```\r\nvar default_filter = $(\"#filter_default\").val();\r\n\t\t\r\n$(\"#vedit-filter\").select2({\r\n\tplaceholder: {\r\n\t\tid: default_filter, // or whatever the placeholder value is\r\n\t\ttext: default_filter // the text to display as the placeholder\r\n\t},\r\n...\r\n```\r\n\r\nremote data when no results are found.  You must return an array or else it errors : \r\n```\r\n// 0 results send a message back to say so.\r\n$ajax_result['results'][] = array(\r\n\t'id' => 0,\r\n\t'text' => 'No results found...'\r\n);\r\n```\r\n\r\nNow checking the form values you can see what happens.\r\n\r\nUpon load of the page it is correct : CORRECT\r\nsettings%5Bfilter%5D=stephen.exe&settings%5Boriginal%5D=stephen.exe\r\n\r\nSearching and setting to another value : CORRECT\r\nsettings%5Bfilter%5D=richard.exe&settings%5Boriginal%5D=stephen.exe\r\n\r\nClearing the current value (shows stephen.exe default in the box) : CORRECT\r\nsettings%5Bfilter%5D=stephen.exe&settings%5Boriginal%5D=stephen.exe\r\n\r\nSearching and clicking on the 'No results found...' (shows stephen.exe default in the box) : WRONG\r\nsettings%5Boriginal%5D=stephen.exe\r\n\r\nSo, how can I still 'return' a no results message when there are no remote data results, YET still keep the placeholder acting correctly?  When they click on the 'no results' the input box reverts back to the default of stephen.exe, but the form value is lost."}}