mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-08-20 10:06:07 +08:00
added setting to allow the customization of the field at content level
This commit is contained in:
parent
a4be7c68cb
commit
d2cb962e2b
@ -96,12 +96,13 @@ namespace Orchard.Fields.Drivers {
|
||||
Name = field.DisplayName,
|
||||
Hint = settings.Hint,
|
||||
IsRequired = settings.Required,
|
||||
AllowDisplayOptionsOverride = settings.AllowDisplayOptionsOverride,
|
||||
Editor = new DateTimeEditor() {
|
||||
Date = showDate ? DateLocalizationServices.ConvertToLocalizedDateString(value, options) : null,
|
||||
Time = showTime ? DateLocalizationServices.ConvertToLocalizedTimeString(value, options) : null,
|
||||
ShowDate = showDate,
|
||||
ShowTime = showTime,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return ContentShape("Fields_DateTime_Edit", GetDifferentiator(field, part),
|
||||
|
||||
@ -42,6 +42,7 @@ namespace Orchard.Fields.Settings {
|
||||
builder.WithSetting("DateTimeFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture));
|
||||
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);
|
||||
builder.WithSetting("DateTimeFieldSettings.AllowDisplayOptionsOverride", model.AllowDisplayOptionsOverride.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
yield return DefinitionTemplate(model);
|
||||
}
|
||||
|
||||
@ -15,5 +15,6 @@ namespace Orchard.Fields.Settings {
|
||||
public bool Required { get; set; }
|
||||
public DateTime? DefaultValue { get; set; }
|
||||
public DateTimeEditor Editor { get; set; }
|
||||
public bool AllowDisplayOptionsOverride { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Orchard.Core.Common.ViewModels;
|
||||
using Orchard.Fields.Settings;
|
||||
|
||||
namespace Orchard.Fields.ViewModels {
|
||||
public class DateTimeFieldViewModel {
|
||||
@ -6,5 +7,7 @@ namespace Orchard.Fields.ViewModels {
|
||||
public string Hint { get; set; }
|
||||
public bool IsRequired { get; set; }
|
||||
public DateTimeEditor Editor { get; set; }
|
||||
public bool AllowDisplayOptionsOverride { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@ -2,13 +2,16 @@
|
||||
@using Orchard.Fields.Settings;
|
||||
|
||||
<fieldset>
|
||||
<label for="@Html.FieldIdFor(m => m.Display)" class="forcheckbox">@T("Display options")</label>
|
||||
<label for="@Html.FieldIdFor(m => m.Display)" class="forcheckbox">@T("Display options")</label>
|
||||
<select id="@Html.FieldIdFor(m => m.Display)" name="@Html.FieldNameFor(m => m.Display)">
|
||||
@Html.SelectOption(DateTimeFieldDisplays.DateAndTime, Model.Display == DateTimeFieldDisplays.DateAndTime, T("Date and time").ToString())
|
||||
@Html.SelectOption(DateTimeFieldDisplays.DateOnly, Model.Display == DateTimeFieldDisplays.DateOnly, T("Date only").ToString())
|
||||
@Html.SelectOption(DateTimeFieldDisplays.TimeOnly, Model.Display == DateTimeFieldDisplays.TimeOnly, T("Time only").ToString())
|
||||
</select>
|
||||
|
||||
</select>
|
||||
<div>
|
||||
@Html.CheckBoxFor(m => m.AllowDisplayOptionsOverride) <label for="@Html.FieldIdFor(m => m.AllowDisplayOptionsOverride)" class="forcheckbox">@T("Allow override")</label>
|
||||
<span class="hint">@T("Check to allow users to specify the Display options value in each content.")</span>
|
||||
</div>
|
||||
@Html.ValidationMessageFor(m => m.Display)
|
||||
</fieldset>
|
||||
|
||||
|
||||
@ -1,9 +1,15 @@
|
||||
@model Orchard.Fields.ViewModels.DateTimeFieldViewModel
|
||||
|
||||
|
||||
<fieldset>
|
||||
<label for="@Html.FieldIdFor(m => Model.Editor.Date)" @if (Model.IsRequired) { <text> class="required" </text> }>@Model.Name</label>
|
||||
@Html.EditorFor(m => m.Editor)
|
||||
@if (HasText(Model.Hint)) {
|
||||
@if (Model.AllowDisplayOptionsOverride) {
|
||||
<span class="hint">SPECIFICAMI QUESTO</span>
|
||||
}
|
||||
|
||||
@if (HasText(Model.Hint))
|
||||
{
|
||||
<span class="hint">@Model.Hint</span>
|
||||
}
|
||||
</fieldset>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user