Restricting fields
The properties key field.<fieldName>.groups
specifies the following:
Content types of items available in the field's selection field.
Content types available in the field's content picker,
The following conditions are required to use this property:
The property's key
<fieldname>
must be of type Record (or one of its subclasses).The content types listed in the property's value are subclasses of the key's content type.
Following the procedure in Creating properties files, create or open open the appropriate
.properties
file.In the properties file, add a line of the form
field.<fieldName>.groups=className[,className ...]
. Ensure the class name is fully qualified.
The following snippets describe how to use this property.
Step 1: Create model
public class Article extends Content { private Media media; 1 }
Declares a field |
Step 2: Create subclasses
public class HiResImage extends Media { } public class LowResImage extends Media { }
In the previous snippet, the classes HiResImage
and LowResImage
are subclasses of the content type Media
in the snippet Model for restricting fields.
Step 3: Create property file
field.media.groups=brightspot.core.article.HiResImage,brightspot.core.article.LowResImage
In the previous snippet, the property field.media.groups
limits the selection field and the content picker to types of HiResImage
and LowResImage
—as well as to type Media
.