It would be simpler if the DialogButton allowed a form property like a regular button. Then the <EditForm> control with an id with the same id would validate when the DialogButton is clicked. Is it possible to add a form propr
Hi Ian,
As already mentioned, our SfDialog component does not provide support for build-in dialog buttons inside the form. If you wish to add form validation, you can add the dialog buttons inside the <ChildContent> tag like in the below code.
<SfDialog @bind-Visible="@IsVisible" Width="300px" ShowCloseIcon="true" IsModal="true" Header="Dialog Form validation"> <ChildContent> <EditForm Model="@exampleModel" OnValidSubmit="HandleValidSubmit"> <div style="padding: 10px"> <h5>Name: </h5> <InputText id="name" @bind-Value="exampleModel.Name" /> <DataAnnotationsValidator /> <ValidationSummary Model="exampleModel.Name" /> <br /> </div> <div class="e-footer-content"> <button class="e-btn e-primary e-flat" @onclick="@OnClick" type="submit">Submit</button> </div> </EditForm> </ChildContent> </SfDialog> |
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SFDIAL_1-621755171_(2)1588699304
Please check the above sample and code and let us know if you have any further assistance.
Regards,
Buvana S
Hello Buvana,
according to https://stackoverflow.com/questions/55975262/how-to-place-submit-button-for-a-blazor-editform-outside-of-the-component this should be pretty easy.
The SfDialog is a nice component, but if the DialogButtons are no more used it looses value. Since the DialogButton is probably a wrapper on a normal button, it seems you just have to add the property "form" to the DialogButton and it should work?!
That would be nice for me and probably others.
Hi Brian,
Thank you for reaching out to us with your suggestion. We truly appreciate your feedback and are glad to assist you.
As per your suggestion, you can achieve this by adding an "id" attribute to the EditForm and then assigning this "id" to the "form" attribute of the DialogButton. This will allow the Dialog button to function correctly outside the EditForm.
Below is a code snippet demonstrating how you can implement this:
<SfDialog @bind-Visible="@IsVisible" Width="300px" ShowCloseIcon="true" IsModal="true" Header="Dialog Form validation"> <DialogTemplates> <Content> <EditForm id="editForm" Model="@exampleModel" OnValidSubmit="HandleValidSubmit"> <div style="padding: 10px"> <h5>Name: </h5> <InputText id="name" @bind-Value="exampleModel.Name" /> <DataAnnotationsValidator /> <ValidationSummary Model="exampleModel.Name" /> <br /> </div> </EditForm> </Content> </DialogTemplates> <DialogButtons> <DialogButton Content="Submit" IsPrimary="true" Type="ButtonType.Submit" form="editForm"></DialogButton> </DialogButtons> </SfDialog> |