#19570: TextField does not support the Required Attribute

Work Item: 19570
This commit is contained in:
j3ffb 2013-10-25 15:46:37 +02:00 committed by agriffard
parent df60ed18f8
commit 3e5c9cf951
6 changed files with 17 additions and 7 deletions

View File

@ -1 +1,3 @@
@Html.TextBox("Text", (string)Model.Text, new { @class = "text large" })
@(Model.Required != null && Model.Required
? Html.TextBox("Text", (string)Model.Text, new { @class = "text large", required = "required" })
: Html.TextBox("Text", (string)Model.Text, new { @class = "text large" }))

View File

@ -1 +1,3 @@
@Html.TextBox("Text", (string)Model.Text, new { @class = "text small" })
@(Model.Required != null && Model.Required
? Html.TextBox("Text", (string)Model.Text, new { @class = "text small", required = "required" })
: Html.TextBox("Text", (string)Model.Text, new { @class = "text small" }))

View File

@ -1 +1,3 @@
@Html.TextArea("Text", (string)Model.Text, 10, 80, new {})
@(Model.Required != null && Model.Required
? Html.TextArea("Text", (string)Model.Text, 10, 80, new { required = "required" })
: Html.TextArea("Text", (string)Model.Text, 10, 80, new { }))

View File

@ -1 +1,3 @@
@Html.TextBox("Text", (string)Model.Text, new { @class = "text medium" })
@(Model.Required != null && Model.Required
? Html.TextBox("Text", (string)Model.Text, new { @class = "text medium", required = "required" })
: Html.TextBox("Text", (string)Model.Text, new { @class = "text medium" }))

View File

@ -2,4 +2,6 @@
@{
string editorFlavor = Model.EditorFlavor;
}
@Html.TextArea("Text", (string)Model.Text, 25, 80, new { @class = editorFlavor.HtmlClassify() })
@(Model.Required != null && Model.Required
? Html.TextArea("Text", (string)Model.Text, 25, 80, new { @class = editorFlavor.HtmlClassify(), required = "required" })
: Html.TextArea("Text", (string)Model.Text, 25, 80, new { @class = editorFlavor.HtmlClassify() }))

View File

@ -3,11 +3,11 @@
<fieldset>
<label for="@Html.FieldIdFor(m => m.Text)" @if(Model.Settings.Required) { <text>class="required"</text> }>@Model.Field.DisplayName</label>
@if (String.IsNullOrWhiteSpace(Model.Settings.Flavor)) {
@Html.TextBoxFor(m => m.Text, new { @class = "text" })
@(Model.Settings.Required ? Html.TextBoxFor(m => m.Text, new {@class = "text", required = "required"}) : Html.TextBoxFor(m => m.Text, new {@class = "text"}))
@Html.ValidationMessageFor(m => m.Text)
}
else {
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor)
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor, Required: Model.Settings.Required)
}
@if (HasText(Model.Settings.Hint)) {
<span class="hint">@Model.Settings.Hint</span>