QuestionIn a wizard built with
wuic-parametric-dialog and
isWizard=true, Next blocks me when a field of the current step is invalid. Going back with Previous does not. Is that expected, and how do I validate the step when the user goes back too?
AnswerYes, it is expected: only Next validates the current step. Previous moves back without checking anything.
WhyThe two buttons call the same navigation method on the datasource with different flags.
selectNextVisibleTab() calls
setSelectedTab(tabName) with validation on: it evaluates the validation rules of the columns of the current step, and if one fails it shows a warning toast and stays on the step.
selectPreviousVisibleTab() calls
setSelectedTab(tabName, false, true), where the third argument is
skipValidation. The idea is that going back to fix something should never be blocked by what you have not filled in yet. Hidden steps are skipped in both directions.
The last gate is the Complete button: its
disable_callback is
return !datasource.canCompleteWizard(), which keeps it disabled while any validation rule on a visible step is marked invalid.
Validating on Previous tooOverride the
action_callback of the Previous custom action and call
setSelectedTab yourself, leaving
skipValidation at its default. In the callback the datasource is available as
datasource:
const tabs = datasource.metaInfo.dataTabs.filter(t => !t.hidden);
const i = tabs.findIndex(t => t.selected);
if (i > 0) {
datasource.setSelectedTab(tabs[i - 1].tabName);
}
Avoid calling
setSelectedTab with a hidden step's name or index without
allowHidden: it returns
false and nothing happens. Keep the
disable_callback as
return !datasource.hasPreviousVisibleTab so the button still disables itself on the first step.
Documentation: Wizard