EnableSubmitWhenChanged keeps submit buttons inactive until a rendered value changes from the initial form state. The example uses FormBuilder fields and DMB-rendered action buttons.

Required field

BooleanFieldBuilder channels

ChannelEnabled
Notification center
Email
Browser push
Cancel

Expected states

InitialSave button disabled
ChangedSave button enabled
ResetSave button disabled again

Code Example

SubmitLocks.cshtml
@{
    IActionItem cancelAction = FormActionItemFactory.Cancel("FormBuilder", "Examples", "Cancel");
    IActionItem resetAction = FormActionItemFactory.Reset();
    IActionItem sentAction = FormActionItemFactory.Sent("Save preferences", IconStruct.Bootstrap("bi-save"), lockUntilChanged: true);
}

@using (Html.FormBuilder()
    .SetAction(Url.Action("SubmitLocks", "FormBuilder"))
    .EnableSubmitWhenChanged()
    .Begin())
{
    @Html.TextFieldBuilderFor(m => m.Title).Render()
    @Html.CheckboxFieldBuilderFor(m => m.EmailEnabled).HideLabel().Render()
    @Html.Button(cancelAction)
    @Html.Button(resetAction)
    @Html.Button(sentAction)
}