.net-coreblazor.net-5

How to disable an entire Blazor EditForm, along with all fields?


In Angular's reactive forms, I'm accustomed to using the convenient form.disable() method, which disables all fields bound to a given form group, including the entire form if needed. Similarly, you can enable them with ease using form.enable().

I'm wondering if there’s an equivalent method available in Blazor's EditForm in .NET5 So far, I haven't come across anything that replicates this functionality. In fact, I haven't even found a straightforward way to iterate through all the fields bound to the model in the form.


Solution

  • You could wrap your form inside a fieldset and bind the disable-property to a boolean-Property like so:

    <form>
        <fieldset disabled="@IsDisabled">
            [... formfields ...]
        </fieldset>
    </form>