How to make a class field required?

Don Rea asked on July 11, 2022 21:41

According to https://docs.xperience.io/k11/custom-development/developing-form-controls/reference-field-editor it should be possible to mark a Kentico 11 module class field as being required by checking a box on the field screen in Modules > Classes, but I see nothing like what is described in the doc. It's a field of data type Text, so I'd think that this option ought to be available if it ever is. What is it I don't know or am not seeing?

Recent Answers


Brenden Kehren answered on July 12, 2022 00:26

Which module class are you referring to?

0 votesVote for this answer Mark as a Correct answer

Don Rea answered on July 12, 2022 14:53 (last edited on July 12, 2022 14:53)

In this case it's Membership/User. I assume that's an out-of-the-box class with the product, though I really don't know (the original build out predates me by several years and I'm trying to figure this out as I go). There is a field called Mobile Number that I don't know if it was an original field or not, but in any case I need it to be required and I see no way of doing that.

There are fields that are required, and I don't see anything on those, either. There are fields that I know for sure were added later by the original developers who built this out, and I don't see anything on those, either. I tried adding a new field just now to see if this was maybe a one-time choice when a field is created, and I don't see anything on that, either.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 12, 2022 15:03

Got it. If you go to Modules > Membership > Classes > User Settings > Fields, you should see all the fields for the User Settings. Likewise, you might find that field in the User class. From there, it's just like any other page type, custom table, etc. Just remember if you perform an upgrade, changes to out of the box fields may be overwritten. If you add fields, those fields, usually remain without issue.

0 votesVote for this answer Mark as a Correct answer

Don Rea answered on July 13, 2022 21:58

Since there seems to be no reference to field requirement anywhere in the admin UI, I ended up directly changing the value of the allowempty attribute of that field to false in the ClassFormDefinition column of the CMS_Class table.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 13, 2022 22:02

If it's in the CMS_Class table, then I'm 99.9% positive it will be in the UI for you to make a change to. It could be locked at the moment but your direct change in the database is NOT recommended at all.

0 votesVote for this answer Mark as a Correct answer

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