For my records, I got a taglist field which saves different phrases within a field.
Earlier, I used a repeater field, but the GUI was to heavy for just simple phrases, so I decided I would like to have this change.
Now with the taglist field, if you type “,” a new tag is created by default. Is there a way to surpress this?
On the other hand, I’ve build a inline form within the records list, where you can also add new phrases to this taglist field. works great, just if you press a space character, the record is opening automatically.
Ok I might have missed a point: My taglist field is saved as jsonable, so I would not need a symbol as a seperator.
I know I need a seperator for the taglist field which has to be comma or space according to the doc. I tested seperator:comma but it didnt work in October3 btw. I wonder why “Enter” is not allowed as the exclusive seperator anyways.
Might be an additional idea: I tried to add values with commas and spaces to this taglist field directly in the code and the database result worked well, same with the taglist field: ["Test With Space","This,Test","Test"]
So if “enter” would be the exclusive seperator, the problem with the comma would automatically be solved.
BUT I hoped to find a solution for this “space” problem in the list, so that the record does not open from the list with the space button.
This way, I could submit names with spaces and commas in this namefield within the record list and save it to the record.
Enter is problematic because it means “submit form” in web browsers. You’ll need to override form widget somehow to configure different separator - something like this for underlying Select2 field: jquery - tokenSeparators in Select2 - Stack Overflow
Ok great, that would work for the taglist field, thanks a lot!
What about the “pressing space in an inputfield which is shown in a partial within the list is opening the record” problem? Do you have a hint here, too? That would be amazing…
I tried to add a JS file in the Constructor of the Controller and within this file, I tried to deal with all kind of methods to overwrite of disable keypress based events, but nothing worked so far…
I found a solution to overwrite the keypress event on space in the List:
Add a JS-File to the Constructor of the Controller: $this->addJs('/plugins/.../.../assets/js/pastespace.js');
pastespace.js
var pasteSpace = function(event) {
if (event.keyCode == '32') {
$(event.target).val($(event.target).val() + ' ');
event.preventDefault();
}
};
window.addEventListener("keydown", pasteSpace, false);
Basically if “space” is pressed, I paste a space to the inputfield of the event and abort the event.
If there’re problems with that solution that I didnt think of, please let me know.