November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
I solved this by extending `ChoiceElementBlock` instead of `InputElementBlockBase`. The functionality I am after (required validation) already exists in the `ChoiceElementBlock` so it was easier to just use that one. Here is my model class, cleaning up some elements so that the "checkbox" functionality is built in:
[ContentType(DisplayName = "Checkbox", GroupName = GroupNames.FormElements, GUID = "...")]
public class CheckboxElementBlock : ChoiceElementBlock
{
[ScaffoldColumn(false)]
public override string Label { get; set; }
[ScaffoldColumn(false)]
public override IEnumerable<OptionItem> Items { get; set; }
[ScaffoldColumn(false)]
public override bool AllowMultiSelect { get; set; }
[ScaffoldColumn(false)]
public override string PredefinedValue { get; set; }
[ScaffoldColumn(false)]
public override string Feed { get; set; }
[Display(
Name = "Label",
Order = -6999)]
public virtual XhtmlString Body { get; set; }
public override void SetDefaultValues(ContentType contentType)
{
base.SetDefaultValues(contentType);
Items = new List<OptionItem>() { new OptionItem { Value = "x", Caption = "x" } };
AllowMultiSelect = true;
Label = null;
}
}
Hello, I have read that you can make a checkbox by using a selection element with only one selection item, however, I also needed to add a link to the "label" so I decided to make my own:
Here is the view:
My problem is that, when I mark this field required (view the RequiredValidator), the validation never passes. It does not matter if the checkbox is checked or not, I still get the message that this field is required. I did some digging (or decompiling) and found this code from the RequiredValidator:
So, I have an idea that the submitted value might be null? Has anyone run into this or know how to solve my issue?