What is the proper way to add a non-base textarea field to the entity form of a custom content entity?
comment and user modules have non-base fields that display in their entity form (comment_body and picture), but it appears these fields are added to the form somewhere besides the main entity form method they use.
In my module, I've created a field and instance inside hook_install
like this:
<?php
function mymodule_install() {
$field = array(
'name' => 'myfield',
'entity_type' => 'myentitytype',
'type' => 'text_long',
'module' => 'text',
'settings' => array(),
'cardinality' => 1,
'locked' => FALSE,
'indexes' => array(),
);
entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => 'myfield',
'entity_type' => 'myentitytype',
'bundle' => 'myentitytype',
'label' => 'Field title',
'description' => t('Field description.'),
'required' => TRUE,
'default_value' => array(),
'settings' => array(
'text_processing' => '0'
),
);
entity_create('field_instance', $instance)->save();
}
I think if I could be pointed to how comment_body gets added to the comment entity form, or picture to the user entity form, I'd be able to resolve this.