Setting default name for form element.

This commit is contained in:
Sipke Schoorstra
2014-10-14 22:58:18 -07:00
parent 61b80af6c7
commit 6d4bef36bd
3 changed files with 4 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ using Orchard.DynamicForms.Services;
using Orchard.Forms.Services;
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Layouts.Framework.Elements;
using Orchard.Layouts.Helpers;
using Orchard.Layouts.Services;
@@ -47,6 +48,7 @@ namespace Orchard.DynamicForms.Drivers {
Id: "FormName",
Name: "FormName",
Title: "Name",
Value: "Untitled",
Classes: new[] { "text", "medium" },
Description: T("The name of the form.")),
_FormAction: shape.Textbox(

View File

@@ -8,7 +8,7 @@ namespace Orchard.DynamicForms.Elements {
}
public string Name {
get { return State.Get("FormName"); }
get { return State.Get("FormName", "Untitled"); }
set { State["FormName"] = value; }
}

View File

@@ -10,7 +10,7 @@ namespace Orchard.Layouts.Helpers {
private static readonly string[] _elementStateBlackList = {"ElementState", "__RequestVerificationToken"};
public static string Get(this StateDictionary state, string key, string defaultValue = null) {
return state == null ? null : state.ContainsKey(key) ? state[key] : null;
return state != null ? state.ContainsKey(key) ? state[key] : defaultValue : defaultValue;
}
public static string Serialize(this StateDictionary state) {