# RequiredValidator not working inside template

**URL:** <https://forum.radzen.com/t/requiredvalidator-not-working-inside-template/5433>\
**Category:** Blazor Server\
**Created:** [October 27, 2020, 8:08pm UTC](https://forum.radzen.com/t/requiredvalidator-not-working-inside-template/5433 "2020-10-27T20:08:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kim](https://forum.radzen.com/user_avatar/forum.radzen.com/kim/32/9988_2.png) [@kim](https://forum.radzen.com/u/kim)\
**Post date:** [October 27, 2020, 8:08pm UTC](https://forum.radzen.com/t/requiredvalidator-not-working-inside-template/5433/1 "2020-10-27T20:08:33Z")

</div>

Hello Radzen Team!

I'm implementing a custom template inside a DataList:

 ![image](https://forum.radzen.com/uploads/default/original/2X/b/b0a5e344a366afda39a54487569bd366e291350f.png)

The template is as follows:

 ![image](https://forum.radzen.com/uploads/default/original/2X/f/f67b3f3a52e73f46ce58eaaf6144fdb1c77e4678.png)

The validators will work with the first item in the list:

 ![image](https://forum.radzen.com/uploads/default/original/2X/a/add37b7a2464cf70e2ff3d645f16a3f6adb9cb4a.png)

And they seem to work for the other items:

 ![image](https://forum.radzen.com/uploads/default/original/2X/f/fa734fb6748265bd3df2fcd24bcdbe5cd1163db6.png)

But in reality, they're all binded to the component in the first item:

 ![image](https://forum.radzen.com/uploads/default/original/2X/7/7de3586df7b793970c3c0abfca5c890ec637c206.png)

My guess is that the template does not resolve the component naming, thus directing all the builded validators to the first item.

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 28, 2020, 7:20am UTC](https://forum.radzen.com/t/requiredvalidator-not-working-inside-template/5433/2 "2020-10-28T07:20:03Z")

</div>

Hi @kim,

Do you have a RadzenTemplateForm inside the template? A form is required for validation to work as expected.

The only other component that supports validation besides the RadzenTemplateForm is the RadzenGrid in inline editing mode. We did that because one cannot nest a `<form>` inside a `<tr>`.

---

<div class="post-metadata">

**Author:** ![kim](https://forum.radzen.com/user_avatar/forum.radzen.com/kim/32/9988_2.png) [@kim](https://forum.radzen.com/u/kim)\
**Post date:** [October 28, 2020, 11:05am UTC](https://forum.radzen.com/t/requiredvalidator-not-working-inside-template/5433/3 "2020-10-28T11:05:09Z")

</div>

I didn't have a RadzenTemplateForm inside the template, so I added one and put all the components inside. Now the project won't build and throws the following error:

 ![image](https://forum.radzen.com/uploads/default/original/2X/7/74ec127e450ac2ef23d705795d7488a1fafbfe2f.png)

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 28, 2020, 11:14am UTC](https://forum.radzen.com/t/requiredvalidator-not-working-inside-template/5433/4 "2020-10-28T11:14:56Z")

</div>

Do you have another template form which is a parent of the datalist? Also you should avoid using TItem="dynamic". Just set the Data property of the template form to globalModelsRuleTime.

---

<div class="post-metadata">

**Author:** ![kim](https://forum.radzen.com/user_avatar/forum.radzen.com/kim/32/9988_2.png) [@kim](https://forum.radzen.com/u/kim)\
**Post date:** [October 28, 2020, 11:21am UTC](https://forum.radzen.com/t/requiredvalidator-not-working-inside-template/5433/5 "2020-10-28T11:21:43Z")

</div>

Yes, there is a parent template form:

```auto
<RadzenTemplateForm Data="@rule" TItem="Global.Models.Rule" Visible="@(rule != null)" Submit="@TemplateFormSubmit">
```

The TItem="dynamic" was automatically generated by Radzen. I then added it as a custom attribute and put the suggested value in the Data property, and here's the final result:

 ![image](https://forum.radzen.com/uploads/default/original/2X/3/3fda8f66bcfa7bd88d4bdcffdfda81cbd08d55ea.png)

However the error still persists:

 ![image](https://forum.radzen.com/uploads/default/original/2X/2/2dee5099fe2cc82736d0dc6f9eefd41546201d39.png)

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 28, 2020, 11:36am UTC](https://forum.radzen.com/t/requiredvalidator-not-working-inside-template/5433/6 "2020-10-28T11:36:58Z")

</div>

Hi @kim,

Nesting of forms is not supported. What exactly are you trying to achieve? I have a feeling it isn't supported by Radzen.

---

<div class="post-metadata">

**Author:** ![kim](https://forum.radzen.com/user_avatar/forum.radzen.com/kim/32/9988_2.png) [@kim](https://forum.radzen.com/u/kim)\
**Post date:** [October 28, 2020, 11:45am UTC](https://forum.radzen.com/t/requiredvalidator-not-working-inside-template/5433/7 "2020-10-28T11:45:30Z")

</div>

I'm trying to implement access rules in my access control app. Every access rule has n amounts of allowed time periods, where each time period has a day of the week, a start datetime and a finish datetime.

The only reason I'm using the validators is to not force initial dates to the user. What I'll do instead is to place a default date in the datepickers and block user attempts to reset it.
