This is a migrated thread and some comments may be shown as answers.

Validation Attributes not working on Kendo Editor

3 Answers 907 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 20 Dec 2018, 12:22 AM

Decorating a string field on a view model with [DataType(DataType.MultilineText)] and [Required] and then creating an @Html.Kendo().EditorFor(x => x.Field) does not add the "data-val-required" validation attribute to the Kendo Editor's underlying textarea element. In fact, no DataAnnotation attribute, nor custom validation attributes that implement ValidationAttribute and IClientModelValidator get handled properly for the Kendo Editor. From what I've seen, other controls seem to handle them just fine.

 

Do you have any plans on adding validation support for the Kendo Editor? We've been working around this by manually adding the html attributes to the controls, but this really isn't desirable as it adds a higher maintenance cost to our application.

3 Answers, 1 is accepted

Sort by
0
Travis
Top achievements
Rank 1
answered on 20 Dec 2018, 12:28 AM
1.
 public class ViewModel
2.{
3.   [Required]
4.   [DataType(DataType.MultilineText)]
5.   public string TextEditor { get; set; }
6.}
0
Travis
Top achievements
Rank 1
answered on 20 Dec 2018, 12:32 AM

Sorry, I mistyped the previous post.

ViewModel:

public class ViewModel
{
   [Required]
   [DataType(DataType.MultilineText)]
   public string TextEditor { get; set; }
}

 

HtmlHelper:

@(Html.Kendo().EditorFor(x => x.TextEditor))

 

Actual Html Result:

<textarea aria-label="editor" cols="20" id="TextEditor" name="TextEditor" rows="5" style="height: 240px; display: none;" type="textarea" data-role="editor" autocomplete="off" class="k-content k-raw-content k-valid" ></textarea>

 

Expected Html Result:

<textarea aria-label="editor" cols="20" id="TextEditor" name="TextEditor" rows="5" style="height: 240px; display: none;" type="textarea" data-role="editor" autocomplete="off" class="k-content k-raw-content k-valid" data-val-required="TextEditor is required."></textarea>

 

 

0
Dimitar
Telerik team
answered on 24 Dec 2018, 08:12 AM
Hello Travis,

I have investigated the described scenario and I can confirm that the observed behavior is related to a bug in the Editor's HtmlHelper for ASP.NET Core. I have logged this issue with high severity in the official Kendo UI GitHub repository and you can start tracking the progress that we make on it from item #4729.

In general, bug fixes are prioritized based on the issues's severity and priority. Currently, there is no exact time frame on when a fix for the discussed issue will be released. Therefore, I would suggest to subscribe to the above linked issue, so that you get notified as soon as the item status changes.

As a temporary workaround until the issue is resolved with an official fix, the validation attributes could be added manually as already suggested. 

Also, as a token of gratitude for helping us discover this issue with the Editor HtmlHelper, I have also updated your Telerik Points.

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Editor
Asked by
Travis
Top achievements
Rank 1
Answers by
Travis
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or