Widget Properties are always required

Graham Roberts asked on August 25, 2023 13:18

When trying to use a TextInputComponent as an EditingComponent in widget properties how do you make it so that it is not required?

The documentation on this page states that you should use the [Required] attribute https://docs.xperience.io/developing-websites/form-builder-development/assigning-editing-components-to-properties#Assigningeditingcomponentstoproperties-Frameworkdataannotationattributes

However, when the [Required] attribute is not used, the field still expects a value when submitting the widget form.

I've also tried using [Required(AllowEmptyStrings = true)] but the field still requires a value to be entered

Correct Answer

Arjan van Hugten answered on August 25, 2023 15:44

You need to make the non required property's nullable.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on August 25, 2023 15:01

When you debug it are you receiving the error on the properties or in the ViewComponent? By default the properties are NOT required and I have not had the same results you are having. I'd highly suggest digging into your ViewComponent and possibly adding some error handling/logic around an empty property value.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.