mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-27 04:19:04 +08:00
Adding the ability to have placeholders for content fields, fixes #5943
This commit is contained in:
@@ -7,6 +7,7 @@ namespace Orchard.Core.Common.Settings {
|
||||
public string Flavor { get; set; }
|
||||
public bool Required { get; set; }
|
||||
public string Hint { get; set; }
|
||||
public string Placeholder { get; set; }
|
||||
public string DefaultValue { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Orchard.Core.Common.Settings {
|
||||
builder.WithSetting("TextFieldSettings.Flavor", model.Settings.Flavor);
|
||||
builder.WithSetting("TextFieldSettings.Hint", model.Settings.Hint);
|
||||
builder.WithSetting("TextFieldSettings.Required", model.Settings.Required.ToString(CultureInfo.InvariantCulture));
|
||||
builder.WithSetting("TextFieldSettings.Placeholder", model.Settings.Placeholder);
|
||||
builder.WithSetting("TextFieldSettings.DefaultValue", model.Settings.DefaultValue);
|
||||
|
||||
yield return DefinitionTemplate(model);
|
||||
|
||||
@@ -9,5 +9,7 @@ namespace Orchard.Core.Common.ViewModels {
|
||||
public string Time { get; set; }
|
||||
public bool ShowDate { get; set; }
|
||||
public bool ShowTime { get; set; }
|
||||
public string DatePlaceholder { get; set; }
|
||||
public string TimePlaceholder { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,10 @@
|
||||
if (Model.AutoFocus == true) {
|
||||
htmlAttributes["autofocus"] = "autofocus";
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(Model.Placeholder)) {
|
||||
htmlAttributes["placeholder"] = Model.Placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
@Html.TextArea("Text", (string)Model.Text, 25, 80, htmlAttributes)
|
||||
@@ -13,6 +13,10 @@
|
||||
if (Model.AutoFocus == true) {
|
||||
htmlAttributes["autofocus"] = "autofocus";
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(Model.Placeholder)) {
|
||||
htmlAttributes["placeholder"] = Model.Placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
@Html.TextArea("Text", (string)Model.Text, 25, 80, htmlAttributes)
|
||||
@@ -19,6 +19,14 @@
|
||||
<span class="hint">@T("The help text is written under the field when authors are editing the content item.")</span>
|
||||
@Html.ValidationMessageFor(m => m.Settings.Hint)
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div class="editor-field">
|
||||
<label for="@Html.FieldIdFor(m => m.Settings.Placeholder)">@T("Watermark (placeholder)")</label>
|
||||
@Html.TextBoxFor(m => m.Settings.Placeholder, new { @class = "text large" })
|
||||
@Html.ValidationMessageFor(m => m.Settings.Placeholder)
|
||||
<span class="hint">@T("A hint to display when the input of text is empty. (optional)")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Display.DefinitionTemplate(TemplateName: "TextFieldDefaultValueEditor", Model: Model)
|
||||
</fieldset>
|
||||
@@ -5,13 +5,13 @@
|
||||
}
|
||||
|
||||
@if (Model.ShowDate) {
|
||||
<label class="forpicker" for="@Html.FieldIdFor(m => Model.Date)">@T("Date")</label>
|
||||
<span class="date">@Html.TextBoxFor(m => m.Date, new { placeholder = T("Date").Text })</span>
|
||||
<label for="@Html.FieldIdFor(m => Model.Date)">@T("Date")</label>
|
||||
<span class="date">@Html.TextBoxFor(m => m.Date, new { placeholder = Model.DatePlaceholder ?? T("Date").Text })</span>
|
||||
}
|
||||
|
||||
@if (Model.ShowTime) {
|
||||
<label class="forpicker" for="@Html.FieldIdFor(m => Model.Time)">@T("Time")</label>
|
||||
<span class="time">@Html.TextBoxFor(m => m.Time, new { placeholder = T("Time").Text })</span>
|
||||
<label for="@Html.FieldIdFor(m => Model.Time)">@T("Time")</label>
|
||||
<span class="time">@Html.TextBoxFor(m => m.Time, new { placeholder = Model.TimePlaceholder ?? T("Time").Text })</span>
|
||||
}
|
||||
|
||||
@if (Model.ShowDate) { <text>@Html.ValidationMessageFor(m => m.Date)</text> }
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
<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)) {
|
||||
@(Model.Settings.Required ? Html.TextBoxFor(m => m.Text, new {@class = "text", required = "required"}) : Html.TextBoxFor(m => m.Text, new {@class = "text"}))
|
||||
@(Model.Settings.Required
|
||||
? Html.TextBoxFor(m => m.Text, new { @class = "text", required = "required", placeholder = Model.Settings.Placeholder })
|
||||
: Html.TextBoxFor(m => m.Text, new { @class = "text", placeholder = Model.Settings.Placeholder }))
|
||||
@Html.ValidationMessageFor(m => m.Text)
|
||||
}
|
||||
else {
|
||||
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor, Required: Model.Settings.Required, ContentItem: Model.ContentItem)
|
||||
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor, Required: Model.Settings.Required, ContentItem: Model.ContentItem, Placeholder: Model.Settings.Placeholder)
|
||||
}
|
||||
@if (HasText(Model.Settings.Hint)) {
|
||||
<span class="hint">@Model.Settings.Hint</span>
|
||||
|
||||
@@ -64,6 +64,8 @@ namespace Orchard.Fields.Drivers {
|
||||
Time = showTime ? DateLocalizationServices.ConvertToLocalizedTimeString(value, options) : null,
|
||||
ShowDate = showDate,
|
||||
ShowTime = showTime,
|
||||
DatePlaceholder = settings.DatePlaceholder,
|
||||
TimePlaceholder = settings.TimePlaceholder
|
||||
}
|
||||
};
|
||||
|
||||
@@ -102,6 +104,8 @@ namespace Orchard.Fields.Drivers {
|
||||
Time = showTime ? DateLocalizationServices.ConvertToLocalizedTimeString(value, options) : null,
|
||||
ShowDate = showDate,
|
||||
ShowTime = showTime,
|
||||
DatePlaceholder = settings.DatePlaceholder,
|
||||
TimePlaceholder = settings.TimePlaceholder
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace Orchard.Fields.Settings {
|
||||
builder.WithSetting("DateTimeFieldSettings.Display", model.Display.ToString());
|
||||
builder.WithSetting("DateTimeFieldSettings.Hint", model.Hint);
|
||||
builder.WithSetting("DateTimeFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture));
|
||||
builder.WithSetting("DateTimeFieldSettings.DatePlaceholder", model.DatePlaceholder);
|
||||
builder.WithSetting("DateTimeFieldSettings.TimePlaceholder", model.TimePlaceholder);
|
||||
model.DefaultValue = model.Editor == null ? model.DefaultValue : _dateLocalizationServices.ConvertFromLocalizedString(model.Editor.Date, model.Editor.Time);
|
||||
builder.WithSetting("DateTimeFieldSettings.DefaultValue", model.DefaultValue.HasValue ? model.DefaultValue.Value.ToString(CultureInfo.InvariantCulture) : String.Empty);
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Orchard.Fields.Settings {
|
||||
public DateTimeFieldDisplays Display { get; set; }
|
||||
public string Hint { get; set; }
|
||||
public bool Required { get; set; }
|
||||
public string DatePlaceholder { get; set; }
|
||||
public string TimePlaceholder { get; set; }
|
||||
public DateTime? DefaultValue { get; set; }
|
||||
public DateTimeEditor Editor { get; set; }
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace Orchard.Fields.Settings {
|
||||
builder.WithSetting("LinkFieldSettings.TargetMode", model.TargetMode.ToString());
|
||||
builder.WithSetting("LinkFieldSettings.LinkTextMode", model.LinkTextMode.ToString());
|
||||
builder.WithSetting("LinkFieldSettings.StaticText", model.StaticText);
|
||||
builder.WithSetting("LinkFieldSettings.UrlPlaceholder", model.UrlPlaceholder);
|
||||
builder.WithSetting("LinkFieldSettings.TextPlaceholder", model.TextPlaceholder);
|
||||
builder.WithSetting("LinkFieldSettings.DefaultValue", model.DefaultValue);
|
||||
builder.WithSetting("LinkFieldSettings.TextDefaultValue", model.TextDefaultValue);
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
public TargetMode TargetMode { get; set; }
|
||||
public LinkTextMode LinkTextMode { get; set; }
|
||||
public string StaticText { get; set; }
|
||||
public string UrlPlaceholder { get; set; }
|
||||
public string TextPlaceholder { get; set; }
|
||||
public string DefaultValue { get; set; }
|
||||
public string TextDefaultValue { get; set; }
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Orchard.Fields.Settings {
|
||||
builder.WithSetting("NumericFieldSettings.Scale", model.Scale.ToString(CultureInfo.InvariantCulture));
|
||||
builder.WithSetting("NumericFieldSettings.Minimum", model.Minimum.HasValue ? model.Minimum.Value.ToString(CultureInfo.InvariantCulture) : string.Empty);
|
||||
builder.WithSetting("NumericFieldSettings.Maximum", model.Maximum.HasValue ? model.Maximum.Value.ToString(CultureInfo.InvariantCulture) : string.Empty);
|
||||
builder.WithSetting("NumericFieldSettings.Placeholder", model.Placeholder);
|
||||
builder.WithSetting("NumericFieldSettings.DefaultValue", model.DefaultValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
public int Scale { get; set; }
|
||||
public decimal? Minimum { get; set; }
|
||||
public decimal? Maximum { get; set; }
|
||||
public string Placeholder { get; set; }
|
||||
public string DefaultValue { get; set; }
|
||||
|
||||
public NumericFieldSettings() {
|
||||
|
||||
@@ -28,6 +28,24 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<div class="editor-field">
|
||||
<label for="@Html.FieldIdFor(m => m.DatePlaceholder)">@T("Watermark (placeholder) for the date")</label>
|
||||
@Html.TextBoxFor(m => m.DatePlaceholder, new { @class = "text large" })
|
||||
@Html.ValidationMessageFor(m => m.DatePlaceholder)
|
||||
<span class="hint">@T("A hint to display when the date is empty. (optional)")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<div class="editor-field">
|
||||
<label for="@Html.FieldIdFor(m => m.TimePlaceholder)">@T("Watermark (placeholder) for the time")</label>
|
||||
@Html.TextBoxFor(m => m.TimePlaceholder, new { @class = "text large" })
|
||||
@Html.ValidationMessageFor(m => m.TimePlaceholder)
|
||||
<span class="hint">@T("A hint to display when the time is empty. (optional)")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.Editor)">@T("Default value")</label>
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<label class="forpicker" for="@Html.FieldIdFor(m => m.DefaultValue)">@T("Default value")</label>
|
||||
<label for="@Html.FieldIdFor(m => m.DefaultValue)">@T("Default value")</label>
|
||||
@Html.TextBoxFor(m => m.DefaultValue, new { @class = "text large tokenized ui-autocomplete-input" })
|
||||
<span class="hint">@T("Enter a default option for the field. You can use tokens in this field. If there is no equivalent choice among Options, it will not be used. (optional)")</span>
|
||||
@Html.ValidationMessageFor(m => m.DefaultValue)
|
||||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
@@ -44,6 +44,22 @@
|
||||
@Html.ValidationMessageFor(m => m.Hint)
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div class="editor-field">
|
||||
<label for="@Html.FieldIdFor(m => m.UrlPlaceholder)">@T("Watermark (placeholder) for the url")</label>
|
||||
@Html.TextBoxFor(m => m.UrlPlaceholder, new { @class = "text large" })
|
||||
@Html.ValidationMessageFor(m => m.UrlPlaceholder)
|
||||
<span class="hint">@T("A hint to display when the input of url is empty. (optional)")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div class="editor-field">
|
||||
<label for="@Html.FieldIdFor(m => m.TextPlaceholder)">@T("Watermark (placeholder) for the text of the link")</label>
|
||||
@Html.TextBoxFor(m => m.TextPlaceholder, new { @class = "text large" })
|
||||
@Html.ValidationMessageFor(m => m.TextPlaceholder)
|
||||
<span class="hint">@T("A hint to display when the input of text is empty. (optional)")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.DefaultValue)">@T("Default value")</label>
|
||||
|
||||
@@ -41,9 +41,17 @@
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div class="editor-field">
|
||||
<label class="forpicker" for="@Html.FieldIdFor(m => m.DefaultValue)">@T("Default value")</label>
|
||||
<label for="@Html.FieldIdFor(m => m.Placeholder)">@T("Watermark (placeholder)")</label>
|
||||
@Html.TextBoxFor(m => m.Placeholder, new { @class = "text large" })
|
||||
@Html.ValidationMessageFor(m => m.Placeholder)
|
||||
<span class="hint">@T("A hint to display when the input is empty. (optional)")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div class="editor-field">
|
||||
<label for="@Html.FieldIdFor(m => m.DefaultValue)">@T("Default value")</label>
|
||||
@Html.TextBoxFor(m => m.DefaultValue, new { @class = "text large tokenized ui-autocomplete-input" })
|
||||
<span class="hint">@T("The default value for the field. It must be a number, and if not it will not shown. Make sure to set the Scale property if the value is not an integer. You can use tokens in this field. (optional)")</span>
|
||||
@Html.ValidationMessageFor(m => m.DefaultValue)
|
||||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<label for="@Html.FieldIdFor(m => m.Value)" @if(settings.Required) { <text>class="required"</text> }>@T("Url")</label>
|
||||
</div>
|
||||
<div class="editor-field">
|
||||
@Html.TextBoxFor(m => m.Value, new { @class = "text large" })
|
||||
@Html.TextBoxFor(m => m.Value, new { @class = "text large", placeholder = settings.UrlPlaceholder })
|
||||
<span class="hint">@T("A valid url, i.e. http://orchardproject.net, /content/file.pdf, ...")</span>
|
||||
</div>
|
||||
@if (!String.IsNullOrWhiteSpace(settings.DefaultValue)) {
|
||||
@@ -35,7 +35,7 @@
|
||||
<label for="@Html.FieldIdFor(m => m.Text)" @if(settings.LinkTextMode == LinkTextMode.Required) { <text>class="required"</text> }>@T("Text")</label>
|
||||
</div>
|
||||
<div class="editor-field">
|
||||
@Html.TextBoxFor(m => m.Text, new { @class = "text medium" })
|
||||
@Html.TextBoxFor(m => m.Text, new { @class = "text medium", placeholder = settings.TextPlaceholder })
|
||||
@if (!String.IsNullOrWhiteSpace(settings.TextDefaultValue)) {
|
||||
<span class="hint">@T("If the field is left empty then the default value will be used.")</span>
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<fieldset>
|
||||
<label for="@Html.FieldIdFor(m => m.Value)" @if(Model.Settings.Required) { <text>class="required"</text> }>@Model.Field.DisplayName</label>
|
||||
@(Model.Settings.Required
|
||||
? Html.TextBoxFor(m => m.Value, new {@class = "text-small", type = "text", min = (Model.Settings.Minimum.HasValue) ? Model.Settings.Minimum.Value : 0, max = (Model.Settings.Maximum.HasValue) ? Model.Settings.Maximum.Value : 1000000, step = Math.Pow(10, 0 - Model.Settings.Scale).ToString(CultureInfo.InvariantCulture), required = "required"})
|
||||
: Html.TextBoxFor(m => m.Value, new {@class = "text-small", type = "text", min = (Model.Settings.Minimum.HasValue) ? Model.Settings.Minimum.Value : 0, max = (Model.Settings.Maximum.HasValue) ? Model.Settings.Maximum.Value : 1000000, step = Math.Pow(10, 0 - Model.Settings.Scale).ToString(CultureInfo.InvariantCulture)}))
|
||||
? Html.TextBoxFor(m => m.Value, new {@class = "text-small", type = "text", min = (Model.Settings.Minimum.HasValue) ? Model.Settings.Minimum.Value : 0, max = (Model.Settings.Maximum.HasValue) ? Model.Settings.Maximum.Value : 1000000, step = Math.Pow(10, 0 - Model.Settings.Scale).ToString(CultureInfo.InvariantCulture), required = "required", placeholder = Model.Settings.Placeholder })
|
||||
: Html.TextBoxFor(m => m.Value, new {@class = "text-small", type = "text", min = (Model.Settings.Minimum.HasValue) ? Model.Settings.Minimum.Value : 0, max = (Model.Settings.Maximum.HasValue) ? Model.Settings.Maximum.Value : 1000000, step = Math.Pow(10, 0 - Model.Settings.Scale).ToString(CultureInfo.InvariantCulture), placeholder = Model.Settings.Placeholder }))
|
||||
@Html.ValidationMessageFor(m => m.Value)
|
||||
@if (HasText(Model.Settings.Hint)) {
|
||||
<span class="hint">@Model.Settings.Hint</span>
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
|
||||
@if (Model.ShowDate) {
|
||||
<label class="forpicker" for="@Html.FieldIdFor(m => Model.Date)">@T("Date")</label>
|
||||
<span class="date">@Html.TextBoxFor(m => m.Date, new { placeholder = T("Date").Text, @class = "text" })</span>
|
||||
<span class="date">@Html.TextBoxFor(m => m.Date, new { placeholder = Model.DatePlaceholder ?? T("Date").Text, @class = "text" })</span>
|
||||
}
|
||||
|
||||
@if (Model.ShowTime) {
|
||||
<label class="forpicker" for="@Html.FieldIdFor(m => Model.Time)">@T("Time")</label>
|
||||
<span class="time">@Html.TextBoxFor(m => m.Time, new { placeholder = T("Time").Text, @class = "text" })</span>
|
||||
<span class="time">@Html.TextBoxFor(m => m.Time, new { placeholder = Model.TimePlaceholder ?? T("Time").Text, @class = "text" })</span>
|
||||
}
|
||||
|
||||
@if (Model.ShowDate) { <text>@Html.ValidationMessageFor(m => m.Date)</text> }
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
|
||||
@if (Model.ShowDate) {
|
||||
<label class="forpicker" for="@Html.FieldIdFor(m => Model.Date)">@T("Date")</label>
|
||||
<span class="date">@Html.TextBoxFor(m => m.Date, new { placeholder = T("Date").Text, @class = "text" })</span>
|
||||
<span class="date">@Html.TextBoxFor(m => m.Date, new { placeholder = Model.DatePlaceholder ?? T("Date").Text, @class = "text" })</span>
|
||||
}
|
||||
|
||||
@if (Model.ShowTime) {
|
||||
<label class="forpicker" for="@Html.FieldIdFor(m => Model.Time)">@T("Time")</label>
|
||||
<span class="time">@Html.TextBoxFor(m => m.Time, new { placeholder = T("Time").Text, @class = "text" })</span>
|
||||
<span class="time">@Html.TextBoxFor(m => m.Time, new { placeholder = Model.TimePlaceholder ?? T("Time").Text, @class = "text" })</span>
|
||||
}
|
||||
|
||||
@if (Model.ShowDate) { <text>@Html.ValidationMessageFor(m => m.Date)</text> }
|
||||
|
||||
Reference in New Issue
Block a user