Force Validate on Step

Hi, so I'm setting up an Add form using Steps and I've put required validators on the fields of the first step, however the validators don't fire when I go to step 2. How can I force the validators to fire before allowing the user to go to the second step?

1 Like

Hi @kgordon,

It turned out that this isn't possible at the moment due to lack of integration between the steps and the form. We will investigate what could be done about it as this a scenario we would like to support. I will update this thread once there is progress.

1 Like

Ok thanks! I'll keep an eye open for a solution.

I'm curious about this too. Is there a timeline of when we can expect this functionality?

Hi @dajones,

This has been implemented a few months back. The Steps component will trigger validation if placed inside a RadzenTemplateForm.

1 Like

Actually let me change my question. I have actions that take place on the change event of the step. I want to prevent these actions from taking place if the step fails validation. How would I do that? Is there a value that is set indicating validation failed that I can access?

The Change even will not fire if validation fails. Here is the actual implementation.

internal async System.Threading.Tasks.Task SelectStep(RadzenStepsItem step, bool raiseChange = false)
        var valid = true;

        if (EditContext != null)
            valid = EditContext.Validate();

        var newIndex = steps.IndexOf(step);

        if (valid || newIndex < SelectedIndex)
            SelectedIndex = newIndex;

            if (raiseChange)
                await Change.InvokeAsync(SelectedIndex);
                await SelectedIndexChanged.InvokeAsync(SelectedIndex);

Yeah unfortunately I seem to have found a way around your code :grinning:

It's very likely because I've just now added a template form and put the steps inside the form. However the change event on steps does fire even though the validation fails.

Here's the change event and the debugger showing the code firing

You can see all the validators fired on the form here:

I'm assuming I've done something wrong trying to put the steps control inside the template form. Do I need to enter something in either Action or Method for it to prevent the change event from firing, I've attached a picture of my current design.

We may have reproduced the issue. Although the step does not change the Change event seems to fire sometimes. We are investigating what is causing this problem.

1 Like

This fix should be included in the latest Radzen release.


Working well, thanks so much!