November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi Noel
The Episerver Forms samples code has a date/time element that you might be able to use for inspiration: https://github.com/episerver/EPiServer.Forms.Samples
David
Thanks David, browsing that code showed me "AvailableValidatorTypes
" (which is the answer I needed)
my element's full *.cs file source:
[ContentType(DisplayName = "Date Picker", GroupName = "Basic Elements", GUID = "...")]
[AvailableValidatorTypes(Include = new Type[] { typeof(RequiredValidator) })]
public class DateElementBlock : TextboxElementBlock
{
public DateElementBlock() : base() { }
[ScaffoldColumn(false)]
public override string PredefinedValue { get { return base.PredefinedValue; } set { base.PredefinedValue = value; } }
[ScaffoldColumn(false)]
public override string PlaceHolder { get { return base.PlaceHolder; } set { base.PlaceHolder = value; } }
}
I'm making a custom Form Element of "Date" type, so I'm extending "TextboxElementBox" like so...
My custom element will be
but because I'm extending TextboxElementBlock the editor displays a few validation options...
which are not appropriate. I did TRY and create a custom element with a custom validator, but the client side custom error message is not displayed correctly, so I figured as the browser will ensure that the "date" field will have a proper date if it has anything in it at all, so If I could remove all the validation options above except the "Required" validator then my problem would be sorted.
I tried to override the value returned by
inside
DateElementBlock.cs
, but that only returns a list of ACTIVE validators, so it doesn't control the list of validators presented to the editors.I think this may require a dojo solution, and I've already inspected the zip files (EPiServer.Forms.zip and EPiServer.Forms.UI.zip) and I'm hoping it works similar to adding a custom element (copy ascx/js file from zip into correct folder location).
Anyone done anything similar in the past?