I have created a new field as per post in the old forum.
public class GenesisSignature : Umbraco.Forms.Core.FieldType
{
public override string GetDesignView() =>
“/App_Plugins/IBDGenesis/UUI-Signature/signature.html”;
public GenesisSignature()
{
this.Id = new Guid(“78f429e3-d27d-4696-8028-5c8830d73909”);
this.Alias = “genesisSignature”;
this.Name = “Signature Pad”;
this.Description = “Displays a canvas to capture a signature or alternativly a text edit box with a generated signature.”;
this.Icon = “wand-magic-sparkles deep-orange”;
this.SortOrder = 100;
this.SupportsRegex = true;
this.SupportsMandatory = true;
this.FieldTypeViewName = “/wwwroot/App_Plugins/IBDGenesis/UUI-Signature/UUI-Signature.cshtml”;
this.DataType = FieldDataType.LongString;
this.RenderInputType = RenderInputType.Single;
}
// Add any custom settings for your field type using the [Setting] attribute
[Setting("Custom Class", Description = "Add a Custom Class to the field", View = "TextField")]
public string CustomClass { get; set; }
[Setting("Image Type", Description = "Use a Prefered Image file type. Default is PNG", View = "TextField")]
public string ImageType { get; set; }
[Setting("Background Color", Description = "Add a background colour in rgba format ie. '150, 150, 0,0.5'", View = "TextField")]
public string BackgroundColour { get; set; }
// You can do custom validation in here which will occur when the form is submitted.
// Any strings returned will cause the submission to be considered invalid.
// Returning an empty collection of strings will indicate that it's valid to proceed.
public override IEnumerable<string> ValidateField(Form form, Field field, IEnumerable<object> postedValues, HttpContext context, IPlaceholderParsingService placeholderParsingService, IFieldTypeStorage fieldTypeStorage)
{
var returnStrings = new List<string>();
if (!postedValues.Any(value => value.ToString().ToLower().Contains("custom")))
{
returnStrings.Add("You need to include 'custom' in the field!");
}
// Also validate it against the default method (to handle mandatory fields and regular expressions)
return base.ValidateField(form, field, postedValues, context, placeholderParsingService, fieldTypeStorage, returnStrings);
}
}
public class Startup : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.WithCollectionBuilder()
.Add();
}
}
cshtml
@using Umbraco.Forms.Web@model Umbraco.Forms.Web.Models.FieldViewModel
<!-- The below CSS and JS needs moving out of this file only added here for testing -->
@{Html.AddFormThemeCssFile(“/App_Plugins/IBDGenesis/UUI-Signature/UUI-Signature.css”);}
When I submit the form the text “You need to include ‘custom’ in the field!” keeps coming up as if the validation error.