function unique_field_constraint_test_entity_base_field_info_alter
Same name in other branches
- 8.9.x core/modules/system/tests/modules/unique_field_constraint_test/unique_field_constraint_test.module \unique_field_constraint_test_entity_base_field_info_alter()
- 10 core/modules/system/tests/modules/unique_field_constraint_test/unique_field_constraint_test.module \unique_field_constraint_test_entity_base_field_info_alter()
- 11.x core/modules/system/tests/modules/unique_field_constraint_test/unique_field_constraint_test.module \unique_field_constraint_test_entity_base_field_info_alter()
Implements hook_entity_base_field_info_alter().
File
-
core/
modules/ system/ tests/ modules/ unique_field_constraint_test/ unique_field_constraint_test.module, line 13
Code
function unique_field_constraint_test_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
if ($entity_type->id() === 'entity_test_string_id') {
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields['name']->addConstraint('UniqueField');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.