When using a custom FieldSettingType on a custom FieldType i get an exception.
When I add the custom FieldType to a form the setting are working. But after the form has been saved in can not be opened since an exception are being thrown.
It seems like it can not set the custom FieldSettingType
[Umbraco.Forms.Core.Attributes.Setting("Lists to include", description = "The selected lists the user can subscribe to", control = "Upac.CampaignMonitor.ContourExtensions.ListsFieldSetting", assembly = "Upac.CampaignMonitor")] public string ListsToInclude { get; set; }
public override List<object> Values { get { if (cbl != null && cbl.SelectedIndex > -1) { value.Clear(); foreach (ListItem item in cbl.Items) { if (item.Selected) { value.Add(item.Value); } } } return value; } set { this.value = value; } }
#endregion Properties
#region Methods
public override string RenderPreview() { return "<div class=\"checkboxlist\"></div>"; // More to come }
public override string RenderPreviewWithPrevalues(List<object> prevalues) { return "<div class=\"checkboxlist\"></div>"; // More to come }
private ListItem[] GetListItems() { List<ListItem> items = new List<ListItem>(); if (!string.IsNullOrEmpty(ListsToInclude)) { string[] selectedValues = ListsToInclude.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); Api api = new Api(); List<List> lists = api.GetLists(); foreach (string selectedValue in selectedValues) { List firstOrDefault = lists.FirstOrDefault(s => s.ListID == selectedValue); if (firstOrDefault != null) { ListItem listItem = new ListItem(firstOrDefault.Name, firstOrDefault.ListID) { Selected = value.Contains(firstOrDefault.ListID) }; items.Add(listItem); } } } return items.ToArray(); }
It's the /usercontrols/UmbracoContour/EditForm.ascx that needed an update
you can download the update from our build server http://nightly.umbraco.org/Umbraco Contour/ (use the latest build of the work in progress version) and simply replace the /usercontrols/UmbracoContour/EditForm.ascx file
Using custom FieldSettingType on custom FieldType
When using a custom FieldSettingType on a custom FieldType i get an exception.
When I add the custom FieldType to a form the setting are working.
But after the form has been saved in can not be opened since an exception are being thrown.
It seems like it can not set the custom FieldSettingType
Here is the exception
BTW the custom FieldSettingType works perfectly on my custom FieldPreValueSourceType
The source code
Comment author was deleted
Hi Christian,
I only tested it with a custom workflow (which worked), will check this out later today.
Cheers,
Tim
Comment author was deleted
Ok found and fixed the problem,
It's the /usercontrols/UmbracoContour/EditForm.ascx that needed an update
you can download the update from our build server http://nightly.umbraco.org/Umbraco Contour/ (use the latest build of the work in progress version) and simply replace the /usercontrols/UmbracoContour/EditForm.ascx file
Or you could update the file on line 303
change
to
Perfect
Hi,
I'm trying to do something similar with MailChimp, but I couldn't get your code to work.
This line:
is causing me issues in Visual Studio, it reports an Error saying
Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments
Any help much appreciated.
is working on a reply...