Add a required single-value plan entity reference base field.
This commit is contained in:
parent
79704c3c7c
commit
4f4f666c28
|
@ -5,3 +5,4 @@ package: farmOS
|
|||
core_version_requirement: ^10
|
||||
dependencies:
|
||||
- entity:entity
|
||||
- farm:plan
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace Drupal\plan_record\Entity;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityBase;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
|
||||
/**
|
||||
* Defines the Plan record relationship entity.
|
||||
|
@ -43,4 +45,26 @@ class PlanRecord extends ContentEntityBase implements PlanRecordInterface {
|
|||
return $type->label();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
|
||||
$fields = parent::baseFieldDefinitions($entity_type);
|
||||
|
||||
$fields['plan'] = BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel(t('Plan'))
|
||||
->setDescription(t('Associate this plan record relationship with a plan entity.'))
|
||||
->setTranslatable(FALSE)
|
||||
->setCardinality(1)
|
||||
->setSetting('target_type', 'plan')
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'entity_reference',
|
||||
'weight' => 12,
|
||||
])
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->setDisplayConfigurable('view', TRUE);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue