Good morning,
I have a problem with the validation of required fields during creating an Event.
The first time I open the EventEditor the required fields are not marked in red (what is expected - I expect only an error if the user trys to save) end then I close the event by cancel. The next time I want to add an event the required fields are marked in red to be required which confuses the user.
I also tried to add the clearError methode to the cancel functionallity without any impact.
So I solved the issue working for me but for me it is like a workaround and I guess it is a not expected behavoiur I discribed before. I set the skipValidation: true for the fields and create my own validation
const editor = this.features?.taskEdit?.editor;
const widgetMapSeceItIdField = editor?.widgetMap?.seceItId;
const widgetMapAddressField = editor?.widgetMap?.addressField;
const isEmpty = (val: any) =>
val === undefined || val === null || (typeof val === 'string' && val.trim() === '');
const showTempError = (field: any, message: string) => {
field.setError(message);
field.element.classList.add('b-invalid');
setTimeout(() => {
field.clearError(message);
field.element.classList.remove('b-invalid');
}, 3000);
};
const missingSeceItId = isEmpty(seceItId);
const missingAddress = isEmpty(addressField);
if (missingSeceItId || missingAddress) {
if (missingSeceItId && widgetMapSeceItIdField) {
showTempError(widgetMapSeceItIdField, 'Dieses Feld ist erforderlich');
}
if (missingAddress && widgetMapAddressField) {
showTempError(widgetMapAddressField, 'Dieses Feld ist erforderlich');
}
const messages: string[] = [];
if (missingSeceItId) messages.push('Pflichtfeld SeceIT ID fehlt');
if (missingAddress) messages.push('Es wurde keine gültige Adresse eingegeben');
showSnackbar(messages.join(' • '), 'error');
return false;
}Can you have a look if it is a bug or give me a hint if I use the validation a wrong way?
Thanks in advice!
Stefan