Forum Discussion
geekora
Jan 10, 2024Copper Contributor
Resouces / Samples / Ideas for CRUD operations for nested forms (3 or more layers down)
Does anyone know any resources / sample projects / templates for creating, reading, updating and deleting nested forms in Blazor? Preferably using Dapper but even some inspirations for UI would b...
Jaiminsoni
Jan 10, 2024Copper Contributor
While nested forms aren't officially supported in Blazor, there are various approaches and resources to achieve similar functionality:
1. Blazor University:
- Forms: https://learn.microsoft.com/en-us/aspnet/core/blazor/forms/?view=aspnetcore-8.0 provides a comprehensive overview of Blazor forms, including using the EditForm component and managing form state. This is a good starting point to understand Blazor forms fundamentals.
2. Microsoft Learn:
- ASP.NET Core Blazor forms binding: https://learn.microsoft.com/en-us/aspnet/core/blazor/forms/binding?view=aspnetcore-8.0 discusses nesting and binding child forms through inheritance of Editor<T>. This approach allows validation and binding for complex nested models.
3. Sample Projects and Templates:
- Blazor Templates (Github): https://github.com/topics/blazor-template offers various templates, including "Complex Form with Nested EditForm" with an example of adding and removing nested forms dynamically.
- MudBlazor (Community Library): https://mudblazor.com/getting-started/installation provides numerous components and features, including a MudForm component with nested functionality. You can find code examples on their website.
4. Additional Resources:
- Stack Overflow: Searching for "Blazor nested forms" on Stack Overflow often leads to discussions and potential solutions for specific scenarios.
- Blog Posts: Articles like "Managing Complex Forms in Blazor" by Daniel Stern (2021) explore ways to handle multi-step forms and nested data models.
5. Important Notes:
- Nested forms require careful management of data binding and validation, especially for dynamic adding and removal.
- Consider using component libraries like MudBlazor that simplify nested form handling with dedicated components.
- Remember to test your form logic thoroughly for different scenarios.
By exploring these resources and approaches, you can effectively create, read, update, and delete nested forms in your Blazor applications.
If you have specific questions or need further guidance on your project, feel free to ask!