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.

2 Answers 2


It is not possible to define field types which are only applicable to certain bundles. I think you need hook_form_alter for the form where the fields are chosen for a bundle to achieve that.


After some further research I will answer with what I found:

In order to make a field type be unavailable on the manage fields page there is an option in the FieldType annotion plugin called $no_ui which must be set to TRUE as documented here.

Then the field can still be added to specific content types using BaseFieldDefinition::create() in hook_entity_base_field_info or to bundles using the less common hook_entity_bundle_field_info plus hook_entity_field_storage_info.

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.