Allow to dynamically create elements with purely numeric names in a selector type

Before this was not possible, as this was messed up with the DB ids. Now we prefix the new created values with a special prefix, to mark them as new.

This fixes issue #381
This commit is contained in:
Jan Böhmer 2023-09-24 15:28:35 +02:00
parent 7195bd6cd6
commit 198befe2bc
3 changed files with 10 additions and 6 deletions

View file

@ -43,7 +43,6 @@ export default class extends Controller {
selectOnTab: true,
maxOptions: null,
create: allowAdd ? this.createItem.bind(this) : false,
createFilter: /\D/, //Must contain a non-digit character, otherwise they would be recognized as DB ID
searchField: [
{field: "text", weight : 2},
@ -72,7 +71,8 @@ export default class extends Controller {
createItem(input, callback) {
callback({
value: input,
//$%$ is a special value prefix, that is used to identify items, that are not yet in the DB
value: '$%$' + input,
text: input,
not_in_db_yet: true,
});