came across this
Overriding default providers in Umbraco Forms
This is a new feature in Forms 6.0.3+ that makes it possible to override & inherit the original provider, be it a Field Type or Workflow etc. The only requirement when inheriting a fieldtype that you wish to override is to ensure you do not override/change the Id set for the provider, and make sure your class is public.
Here is an example of overriding the Textarea field aka Long Answer that is taken from Per's CodeGarden 17 talk, which has been updated for Forms 8.
public class TextareaWithCount : Umbraco.Forms.Core.Providers.FieldTypes.Textarea
{
// Added a new setting when we add our field to the form
[Umbraco.Forms.Core.Attributes.Setting("Max length",
Description = "Max length",
View = "TextField")]
public string MaxNumberOfChars { get; set; }
public TextareaWithCount()
{
// Set a different view for this fieldtype
this.FieldTypeViewName = "FieldType.TextareaWithCount.cshtml";
// We can change the default name of 'Long answer' to something that suits us
this.Name = "Long Answer with Limit";
}
public override IEnumerable<string> ValidateField(Form form, Field field, IEnumerable<object> postedValues, HttpContextBase context, IFormStorage formStorage)
{
var baseValidation = base.ValidateField(form, field, postedValues, context, formStorage);
var value = postedValues.FirstOrDefault();
if (value != null && value.ToString().Length < int.Parse(MaxNumberOfChars))
{
return baseValidation;
}
var custom = new List<string>();
custom.AddRange(baseValidation);
custom.Add("String is way way way too long!");
return custom;
}
}
Umbraco forms -max amt in numeric field
Is there a way to limit the number of characters in numeric fields
came across this Overriding default providers in Umbraco Forms This is a new feature in Forms 6.0.3+ that makes it possible to override & inherit the original provider, be it a Field Type or Workflow etc. The only requirement when inheriting a fieldtype that you wish to override is to ensure you do not override/change the Id set for the provider, and make sure your class is public.
Here is an example of overriding the Textarea field aka Long Answer that is taken from Per's CodeGarden 17 talk, which has been updated for Forms 8.
is working on a reply...