mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#16855: When adding a field you may no longer use spaces or special characters (breaks overrides and searching). Added a 'hint' to the UI for the format.
--HG-- branch : dev
This commit is contained in:
@@ -206,6 +206,7 @@ namespace Orchard.ContentTypes.Services {
|
||||
}
|
||||
|
||||
public void AddFieldToPart(string fieldName, string fieldTypeName, string partName) {
|
||||
fieldName = SafeName(fieldName);
|
||||
_contentDefinitionManager.AlterPartDefinition(partName, partBuilder =>
|
||||
partBuilder.WithField(fieldName, fieldBuilder => fieldBuilder.OfType(fieldTypeName))
|
||||
);
|
||||
@@ -215,9 +216,8 @@ namespace Orchard.ContentTypes.Services {
|
||||
_contentDefinitionManager.AlterPartDefinition(partName, typeBuilder => typeBuilder.RemoveField(fieldName));
|
||||
}
|
||||
|
||||
//gratuitously stolen from the RoutableService
|
||||
public string GenerateName(string name) {
|
||||
if ( string.IsNullOrWhiteSpace(name) )
|
||||
private static string SafeName(string name) {
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
return String.Empty;
|
||||
|
||||
var dissallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s\""<>]+");
|
||||
@@ -227,6 +227,12 @@ namespace Orchard.ContentTypes.Services {
|
||||
|
||||
if (name.Length > 128)
|
||||
name = name.Substring(0, 128);
|
||||
return name;
|
||||
}
|
||||
|
||||
//gratuitously stolen from the RoutableService
|
||||
public string GenerateName(string name) {
|
||||
name = SafeName(name);
|
||||
|
||||
while ( _contentDefinitionManager.GetTypeDefinition(name) != null )
|
||||
name = VersionName(name);
|
||||
|
@@ -4,8 +4,9 @@
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<fieldset>
|
||||
<label for="DisplayName">@T("Display Name")</label>
|
||||
<label for="DisplayName">@T("Name")</label>
|
||||
@Html.TextBoxFor(m => m.DisplayName, new {@class = "textMedium", autofocus = "autofocus"})
|
||||
<span class="hint">@T("Use no spaces or special characters. For example, \"MyCustomField\"")</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label for="FieldTypeName">@T("Field Type")</label>
|
||||
|
Reference in New Issue
Block a user