I have the following model
Public Class BaseViewModel
Public Property Id as integer
Public Property Title As String
<DisplayName("Creation Date"), Required(), ScaffoldColumn(False)>
Public Property DateCreation As String
<DisplayName("Creation User"), Required(), ScaffoldColumn(False)>
Public Property UserCreation As String
<DisplayName("Modification Date"), ScaffoldColumn(False)>
Public Property DateModification As String
<DisplayName("Modification User"), ScaffoldColumn(False)>
Public Property UserModification As String
End Class
I've created a partial view named BaseViewModel that has the following HTML
<div id="Detail-Item" class="hidden">
@Using Html.BeginForm("Save", "Agency", Nothing, FormMethod.Post, New With {.id = "Detail-form"})
@<fieldset>
<legend>Agency</legend>
@Html.ValidationSummary()
<div class="editor-label">
@Html.LabelFor(Function(model) model.Id):
</div>
<div class="editor-field">
@Html.TextBoxFor(Function(model) model.Id, New With {.class = "textbox-id input-key textbox-inactive", .data_field = "Id", .readonly = "readonly"})
@Html.ValidationMessageFor(Function(model) model.Id, "*")
</div>
<div class="editor-label">
@Html.LabelFor(Function(model) model.Title):
</div>
<div class="editor-field">
@Html.TextBoxFor(Function(model) model.Title, New With {.class = "textbox-name input-text focus", .data_field = "Title"})
@Html.ValidationMessageFor(Function(model) model.Title, "*")
</div>
<div class="hidden">
@Html.Hidden("UserCreation", String.Empty, New With {.class = "input-audituser", .data_field = "UserCreation"})
@Html.Hidden("UserModification", String.Empty, New With {.class = "input-audituser", .data_field = "UserModification"})
@Html.Hidden("DateCreation", String.Empty, New With {.class = "input-auditdate", .data_field = "DateCreation"})
@Html.Hidden("DateModification", String.Empty, New With {.class = "input-auditdate", .data_field = "DateModification"})
</div>
</fieldset>
End Using
</div>
To render this view I'm using @html.EditForModel. My problem is that even I'm using Html.Hidden for DateCreation and UserCreation model properties the Html generated for these fields contain the "required" data validation attribute.
Is this the way it should work?, if yes how can avoid that?