8 – How do I limit access to a custom field type I have created so that it can only be attached to certain bundles of content?


I have a custom field class. I would like to limit it to specific content types and bundles that I will choose when my custom module is installed and as other content types meet certain criteria. I don’t want it to be available at /admin/structure/types/manage/article/fields/add-field

Is hook_form_alter on the add-field page form my only option or is there an Annotation or API I can use to mark my field as “not available to this content” similar to the way FieldWidgets can be marked as applicable to only certain field types?

Note: I was also planning to add a ConstraintValidator to the field so that it won’t validate if added to the wrong content.