Hi, I am currently evaluating the scheduler pro in a trial version and trying to implement a validation feature in the TaskEditor for a custom boolean field. E.g. show an error label and prevent saving. I figured out how to register a change listener on the field and how to show the error message:
fixed: {
type: 'slideToggle',
weigth: 10,
label: 'L{Fixed}',
name: 'fixed',
listeners: {
//validate a field and show an error label
change(input: any) {
const {source, value} = input
if (value) {
source.setError("error!!")
} else {
source.clearError("error!!")
}
}
}
}
After setting the value to true in the UI I can see the error label and I am unable to save which is great. However it seems that the value of the eventRecord is still updated to true (e.g. also when pressing cancel) and in addition when changing the value back to false in the UI and pressing save the eventRecord is not updated (remains true).
What am I doing wrong? Is this the right approach to do the field validation?
For the error, you could add that validation to the slideToggle widget definition, but that's for the organization of your code, this change listener is fine.
Regarding the updates, we don't recommend updating the value directly in the UI because we have the calculations being handled by some listeners that won't be triggered correctly that way. We need to know how the slideToggle widget to understand what could be causing that non-updating. Could you please share that piece of code with us?
Pay attention that setting that error doesn't mean that the field value won't be updated, those are two separate behaviors by default.
Now I followed your recommendation and moved the code to my own custom widget which extends the default SlideToggle (see below). However the problem still persists