diff --git a/knowledge-base/form-stop-cascading-editcontext.md b/knowledge-base/form-stop-cascading-editcontext.md new file mode 100644 index 0000000000..ac91cdc4fb --- /dev/null +++ b/knowledge-base/form-stop-cascading-editcontext.md @@ -0,0 +1,76 @@ +--- +title: Stop the cascading EditContext for a specific field in the Form +description: Stop the cascading EditContext for a specific field in the Form +type: how-to +page_title: Stop the cascading EditContext for a specific field in the Form +slug: form-stop-cascading-editcontext +position: +tags: +res_type: kb +--- + +## Environment + + + + + + + +
ProductForm for Blazor
+ +## Description + +I would like to stop the cascading `EditContext` for a specific editor in my Form. The Editor should still be in the Form, but should not be validated. This would also allow me to not provide a `ValueExpression`. + +## Solution + +To stop the cascading `EditContext` for a specific editor in the TelerikForm you should use the [Template]({%slug form-formitems-template%}) and wrap the custom editor in a `` tag. In the `Value` attribute of the `CascadingValue` you should reset the `EditContext`. + +````CSHTML +@* Stop the cascading EditContext for the Edit the DoB checkbox. *@ + +@using System.ComponentModel.DataAnnotations + + + + + + + + + + + + + + + + +@code { + public Person person = new Person(); + + private bool Enabled { get; set; } + + private void OnChange(bool value) + { + Enabled = value; + } + + public class Person + { + [Editable(false)] + public int Id { get; set; } = 10; + [Required] + public string FirstName { get; set; } = "John"; + [Required] + public string LastName { get; set; } = "Doe"; + public DateTime DOB { get; set; } = DateTime.Today.AddYears(-20); + } +} +```` \ No newline at end of file