I am trying to prepopulate a dropdownlist for the user at a PreValue stage in Umbraco forms. This data will come from an external source (API).
I was initially thinking the you could provide data to the Settings method, but not having much luck and not sure that this is even the best approach?
public class BusinessType : FieldType
{
[Setting("BusinessType", view = "BusinessType", prevalues = "", description = "Prepopulated Business Type Data")]
public string BusType { get; set; } = "BusType";
public BusinessType()
{
Name = "BusinessType";
Id = new Guid("39034376-3c1a-41fa-9673-674512f9d109");
Description = "This is an Business Type API feed";
Icon = "icon-list";
DataType = FieldDataType.String;
SortOrder = 10;
}
public override Dictionary<string, Setting> Settings()
{
var settings = base.Settings();
settings[BusType].prevalues = "One, Two, Three, Four, Five";
return settings;
}
public override IEnumerable<object> ProcessSubmittedValue(Field field, IEnumerable<object> postedValues, HttpContextBase context)
{
var values = new List<object>();
var id = field.Id.ToString();
var businessTypeName = context.Request[id + "BusinessTypeName"];
var selection = string.Join(", ", businessTypeName);
values.Add(selection);
return values;
}
}
Prepopulate a FieldType in Umbraco forms
I am trying to prepopulate a dropdownlist for the user at a PreValue stage in Umbraco forms. This data will come from an external source (API).
I was initially thinking the you could provide data to the Settings method, but not having much luck and not sure that this is even the best approach?
Hey mate, One suggestion that was given on Twitter was "Needs to be a prevalue source type".
https://our.umbraco.com/documentation/add-ons/umbracoforms/Editor/Defining-and-Attaching-Prevaluesources/Prevalue-source-types/
Might help?
Comment author was deleted
yes that's right: but no docs :( https://our.umbraco.com/documentation/Add-ons/UmbracoForms/Developer/Extending/
Comment author was deleted
this can probably help: http://www.nibble.be/?p=217
You've made my Monday.
Thank you so much for that link... Solved my issue!
I wish the documentation was a bit better than what it currently is...
is working on a reply...