0

Have you guys experienced a scenario wherein you have forms with list-type fields (e.g. dropdown, checkbox list, etc) that returns "field is required" when you submit it? The form was able to call ajax and returns a 200 but the response was an HTML with "field is required" message on the list-type fields.

Currently this is happening on our CM environment, we have "preview sites" set up that points to the master database and we want to validate the forms first before publishing them.

Is this expected behavior in CM environment? Will this not happen on CD?

2
  • Not sure if that's relevant, being a CM or CD, are those fields are mandatory and you somehow still see the field is required even when you fill them?
    – AJ -
    Nov 27, 2020 at 13:52
  • Yes the fields are mandatory and returns "field is required" even when I filled them.
    – Lala
    Nov 27, 2020 at 14:02

1 Answer 1

0

Not sure if this is a custom control you created, or out of the box control, but either way. Look at how your mandatory validation is working in the view file.

sc91.local\Views\FormBuilder\FieldTemplates\CheckboxList.cshtml

I do my own validation something like this, and then some js validation if it's required.

@model Sitecore.ExperienceForms.Mvc.Models.Fields.ListBoxViewModel
@{
    var IsRequireClass = string.Empty;
    if (Model.Required)
    {
        IsRequireClass = "required-field";
    }
}
<div class="form-group text-left @IsRequireClass required">
</div>

I hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.