using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace Umbraco.Forms.Core.FieldSetting.Pickers { public class DocumentType : BasePicker { public DocumentType() { ObjectGuid = new Guid("a2cb7800-f571-4787-9638-bc48539a0efb"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace Umbraco.Forms.Core.FieldSetting.Pickers { public class BasePicker : FieldSettingType {
public Guid ObjectGuid { get; set; }
private System.Web.UI.WebControls.DropDownList ddl = new System.Web.UI.WebControls.DropDownList();
private string _val = string.Empty;
public override string Value { get { return ddl.SelectedValue; } set { if (!string.IsNullOrEmpty(value)) _val = value; } }
public override System.Web.UI.WebControls.WebControl RenderControl(Attributes.Setting sender, Form form) {
ddl.ID = sender.GetName();
ddl.Items.Clear(); List<KeyValuePair<String, String>> items = new List<KeyValuePair<String,String>>();
if(ObjectGuid != Guid.Empty){ Guid[] guids = umbraco.cms.businesslogic.CMSNode.getAllUniquesFromObjectType(ObjectGuid); foreach (Guid g in guids) { umbraco.cms.businesslogic.CMSNode node = new umbraco.cms.businesslogic.CMSNode(g); items.Add(new KeyValuePair<string, string>(node.Id.ToString(), node.Text)); } }
Just made the update that makes it possible to plug in custom field setting types
If you upgrade to the latest build of the work in progress version (http://nightly.umbraco.org/Umbraco%20Contour/), and make sure you also add the assembly as a parameter
[Umbraco.Forms.Core.Attributes.Setting("Custom test", description = "Custom test", control = "TestContourCustomFieldSettingType.TestFieldTypeSetting", assembly = "TestContourCustomFieldSettingType")] public string CustomTest { get; set; }
How to create a new FieldSettingType
Is there any example or documentation on how to create your own FieldSettingType?
I need a CheckBoxList
This is what I have so fare
Comment author was deleted
Hi Christian,
Good point, we'll add this to the dev docs and the shared source for now here is the sourcecode for the textfield fieldsetting type
Comment author was deleted
And this for the DocumentType picker
Is that enough info to get you going?
Could it be possible that is can only load settings from Umbraco.Forms.Core and not from other assemblies ?
I have tried your first example and it gives an exception
Comment author was deleted
@Christian,
Yup looks like that is the case currently, untill we have an update ready, is the dropdownlist an option for you?
Comment author was deleted
Hi Christian,
Just made the update that makes it possible to plug in custom field setting types
If you upgrade to the latest build of the work in progress version (http://nightly.umbraco.org/Umbraco%20Contour/), and make sure you also add the assembly as a parameter
Hi Tim
I Could not use the dropdownlist since the prevalues are comming from Campaign Monitor.
I have downloaded the latest build and I can now add the assembly and it works perfectly :-)
Comment author was deleted
Great, glad it works!
is working on a reply...