Is it possible to attach a field to an entity programmatically?
I want to create a new entity, say vehicle, which has radio buttons defined for the brand of the vehicle. I would like this field to not be able to be deleted or modified via the UI.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityYes, it is possible, the function is field_create_instance(). If the field was not created before, you will need to create it with field_create_field() first.
field_create_instance()
if anyone tries to copy and paste. I tried to edit the post but edits must be at least 6 characters.