mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#21219: Fixed that the content type to create is not persisted on Form element.
Work Item: 21219
This commit is contained in:
@@ -81,8 +81,8 @@ namespace Orchard.DynamicForms.Drivers {
|
|||||||
Value: "true",
|
Value: "true",
|
||||||
Description: T("Check this to create a content item based using the submitted values. You will have to select a Content Type here and bind the form fields to the various parts and fields of the selected Content Type.")),
|
Description: T("Check this to create a content item based using the submitted values. You will have to select a Content Type here and bind the form fields to the various parts and fields of the selected Content Type.")),
|
||||||
_ContentType: shape.SelectList(
|
_ContentType: shape.SelectList(
|
||||||
Id: "CreateContentType",
|
Id: "FormBindingContentType",
|
||||||
Name: "CreateContentType",
|
Name: "FormBindingContentType",
|
||||||
Title: "Content Type",
|
Title: "Content Type",
|
||||||
Description: T("The Content Type to use when storing the submitted form values as a content item. Note that if you change the content type, you will have to update the form field bindings."),
|
Description: T("The Content Type to use when storing the submitted form values as a content item. Note that if you change the content type, you will have to update the form field bindings."),
|
||||||
EnabledBy: "CreateContent"),
|
EnabledBy: "CreateContent"),
|
||||||
@@ -143,7 +143,7 @@ namespace Orchard.DynamicForms.Drivers {
|
|||||||
|
|
||||||
// Assign the binding content type to each element within the form element.
|
// Assign the binding content type to each element within the form element.
|
||||||
foreach (var child in element.Elements.Flatten().Where(x => x is FormElement).Cast<FormElement>()) {
|
foreach (var child in element.Elements.Flatten().Where(x => x is FormElement).Cast<FormElement>()) {
|
||||||
child.FormBindingContentType = element.CreateContent == true ? element.ContentType : default(string);
|
child.FormBindingContentType = element.CreateContent == true ? element.FormBindingContentType : default(string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,9 +37,9 @@ namespace Orchard.DynamicForms.Elements {
|
|||||||
set { this.Store(x => x.CreateContent, value); }
|
set { this.Store(x => x.CreateContent, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ContentType {
|
public string FormBindingContentType {
|
||||||
get { return this.Retrieve<string>("CreateContentType"); }
|
get { return this.Retrieve(x => x.FormBindingContentType); }
|
||||||
set { this.Store("CreateContentType", value); }
|
set { this.Store(x => x.FormBindingContentType, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Publication {
|
public string Publication {
|
||||||
|
@@ -47,7 +47,7 @@ namespace Orchard.DynamicForms.Handlers {
|
|||||||
|
|
||||||
// Create content item.
|
// Create content item.
|
||||||
var contentItem = default(ContentItem);
|
var contentItem = default(ContentItem);
|
||||||
if (form.CreateContent == true && !String.IsNullOrWhiteSpace(form.ContentType)) {
|
if (form.CreateContent == true && !String.IsNullOrWhiteSpace(form.FormBindingContentType)) {
|
||||||
contentItem = formService.CreateContentItem(form, context.ValueProvider);
|
contentItem = formService.CreateContentItem(form, context.ValueProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
return;
|
return;
|
||||||
$scope.element.data = decodeURIComponent(args.element.data);
|
$scope.element.data = decodeURIComponent(args.element.data);
|
||||||
$scope.element.name = args.elementEditorModel.name;
|
$scope.element.name = args.elementEditorModel.name;
|
||||||
|
$scope.element.formBindingContentType = args.elementEditorModel.formBindingContentType;
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -42,7 +43,7 @@ var LayoutEditor;
|
|||||||
this.toObject = function () {
|
this.toObject = function () {
|
||||||
var result = this.elementToObject();
|
var result = this.elementToObject();
|
||||||
result.name = this.name;
|
result.name = this.name;
|
||||||
result.formBindingContentType = formBindingContentType;
|
result.formBindingContentType = this.formBindingContentType;
|
||||||
result.children = this.childrenToObject();
|
result.children = this.childrenToObject();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@@ -1 +1 @@
|
|||||||
angular.module("LayoutEditor").directive("orcLayoutForm",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:function(n,i){t.configureForElement(n,i);t.configureForContainer(n,i);n.sortableOptions.axis="y";n.edit=function(){n.$root.editElement(n.element).then(function(t){t.cancel||(n.element.data=decodeURIComponent(t.element.data),n.element.name=t.elementEditorModel.name,n.$apply())})}},templateUrl:i.templateUrl("Form"),replace:!0}});var LayoutEditor;(function(n,t){t.Form=function(i,r,u,f,e,o,s,h,c,l,a,v){var y,p;t.Element.call(this,"Form",i,r,u,f,e);t.Container.call(this,["Grid","Content"],v);y=this;this.isContainable=!0;this.dropTargetClass="layout-common-holder";this.contentType=h;this.contentTypeLabel=c;this.contentTypeClass=l;this.name=o||"Untitled";this.formBindingContentType=s;this.hasEditor=a;this.toObject=function(){var n=this.elementToObject();return n.name=this.name,n.formBindingContentType=s,n.children=this.childrenToObject(),n};p=this.getEditorObject;this.getEditorObject=function(){var t=p();return n.extend(t,{FormName:this.name,FormBindingContentType:this.formBindingContentType})};this.setChildren=function(t){this.children=t;_(this.children).each(function(t){t.parent=y;var i=t.getEditorObject;t.getEditorObject=function(){var t=i();return n.extend(t,{FormBindingContentType:y.formBindingContentType})}})};this.setChildren(v)};t.Form.from=function(n){return new t.Form(n.data,n.htmlId,n.htmlClass,n.htmlStyle,n.isTemplated,n.name,n.formBindingContentType,n.contentType,n.contentTypeLabel,n.contentTypeClass,n.hasEditor,t.childrenFrom(n.children))};t.registerFactory("Form",function(n){return t.Form.from(n)})})(jQuery,LayoutEditor||(LayoutEditor={}));
|
angular.module("LayoutEditor").directive("orcLayoutForm",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:function(n,i){t.configureForElement(n,i);t.configureForContainer(n,i);n.sortableOptions.axis="y";n.edit=function(){n.$root.editElement(n.element).then(function(t){t.cancel||(n.element.data=decodeURIComponent(t.element.data),n.element.name=t.elementEditorModel.name,n.element.formBindingContentType=t.elementEditorModel.formBindingContentType,n.$apply())})}},templateUrl:i.templateUrl("Form"),replace:!0}});var LayoutEditor;(function(n,t){t.Form=function(i,r,u,f,e,o,s,h,c,l,a,v){var y,p;t.Element.call(this,"Form",i,r,u,f,e);t.Container.call(this,["Grid","Content"],v);y=this;this.isContainable=!0;this.dropTargetClass="layout-common-holder";this.contentType=h;this.contentTypeLabel=c;this.contentTypeClass=l;this.name=o||"Untitled";this.formBindingContentType=s;this.hasEditor=a;this.toObject=function(){var n=this.elementToObject();return n.name=this.name,n.formBindingContentType=this.formBindingContentType,n.children=this.childrenToObject(),n};p=this.getEditorObject;this.getEditorObject=function(){var t=p();return n.extend(t,{FormName:this.name,FormBindingContentType:this.formBindingContentType})};this.setChildren=function(t){this.children=t;_(this.children).each(function(t){t.parent=y;var i=t.getEditorObject;t.getEditorObject=function(){var t=i();return n.extend(t,{FormBindingContentType:y.formBindingContentType})}})};this.setChildren(v)};t.Form.from=function(n){return new t.Form(n.data,n.htmlId,n.htmlClass,n.htmlStyle,n.isTemplated,n.name,n.formBindingContentType,n.contentType,n.contentTypeLabel,n.contentTypeClass,n.hasEditor,t.childrenFrom(n.children))};t.registerFactory("Form",function(n){return t.Form.from(n)})})(jQuery,LayoutEditor||(LayoutEditor={}));
|
@@ -14,6 +14,7 @@
|
|||||||
return;
|
return;
|
||||||
$scope.element.data = decodeURIComponent(args.element.data);
|
$scope.element.data = decodeURIComponent(args.element.data);
|
||||||
$scope.element.name = args.elementEditorModel.name;
|
$scope.element.name = args.elementEditorModel.name;
|
||||||
|
$scope.element.formBindingContentType = args.elementEditorModel.formBindingContentType;
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
this.toObject = function () {
|
this.toObject = function () {
|
||||||
var result = this.elementToObject();
|
var result = this.elementToObject();
|
||||||
result.name = this.name;
|
result.name = this.name;
|
||||||
result.formBindingContentType = formBindingContentType;
|
result.formBindingContentType = this.formBindingContentType;
|
||||||
result.children = this.childrenToObject();
|
result.children = this.childrenToObject();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@@ -9,13 +9,13 @@ namespace Orchard.DynamicForms.Services {
|
|||||||
protected override void ToElement(Form element, JToken node) {
|
protected override void ToElement(Form element, JToken node) {
|
||||||
base.ToElement(element, node);
|
base.ToElement(element, node);
|
||||||
element.Name = (string)node["name"];
|
element.Name = (string)node["name"];
|
||||||
element.ContentType = (string)node["formBindingContentType"];
|
element.FormBindingContentType = (string)node["formBindingContentType"];
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FromElement(Form element, DescribeElementsContext describeContext, JToken node) {
|
public override void FromElement(Form element, DescribeElementsContext describeContext, JToken node) {
|
||||||
base.FromElement(element, describeContext, node);
|
base.FromElement(element, describeContext, node);
|
||||||
node["name"] = element.Name;
|
node["name"] = element.Name;
|
||||||
node["formBindingContentType"] = element.ContentType;
|
node["formBindingContentType"] = element.FormBindingContentType;
|
||||||
node["hasEditor"] = element.HasEditor;
|
node["hasEditor"] = element.HasEditor;
|
||||||
node["contentType"] = element.Descriptor.TypeName;
|
node["contentType"] = element.Descriptor.TypeName;
|
||||||
node["contentTypeLabel"] = element.Descriptor.DisplayText.Text;
|
node["contentTypeLabel"] = element.Descriptor.DisplayText.Text;
|
||||||
|
@@ -230,7 +230,7 @@ namespace Orchard.DynamicForms.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ContentItem CreateContentItem(Form form, IValueProvider valueProvider) {
|
public ContentItem CreateContentItem(Form form, IValueProvider valueProvider) {
|
||||||
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(form.ContentType);
|
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(form.FormBindingContentType);
|
||||||
|
|
||||||
if (contentTypeDefinition == null)
|
if (contentTypeDefinition == null)
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user