Is there any way to call createSearchChoice programmatically?
When the page loads we might have a "name" or an "id", if it's an "id" we can use "initSelection" and that will populate the select2 input with the data coming from the server.
However if we just have the "name", I'd like to populate the input with that value to create a new record.
createSearchChoice: function(name) {
return { id: 0, text: name + ' (create new person)', new_person_name: name };
},
I've tried just setting the value like it says in the docs but I think that only works for items that already exist.
Select2 is attached to a text input.
Thanks