protected function IefTableViewModeTestTrait::configureFieldAndWidget in Inline Entity Form Table View Mode 8.2
Create an entity reference field and configure it with the widget.
Parameters
string $entity_type_id: The entity type id to which the field will be created.
string $bundle: The bundle name to which the field will be attached.
string $field_name: The field name of the new field.
string|null $target_type: The entity type to reference.
array $target_bundles: The bundles to reference.
string $form_mode: The form mode to configure the widget.
Throws
\Drupal\Core\Entity\EntityStorageException
1 call to IefTableViewModeTestTrait::configureFieldAndWidget()
- ViewModeIefTableTest::testViewMode in tests/
src/ Functional/ ViewModeIefTableTest.php - Check the creation of the view mode ief_table automatically.
File
- tests/
src/ Traits/ IefTableViewModeTestTrait.php, line 37
Class
- IefTableViewModeTestTrait
- Provides common functionality for the IEF table view mode test classes.
Namespace
Drupal\Tests\ief_table_view_mode\TraitsCode
protected function configureFieldAndWidget($entity_type_id, $bundle, $field_name, $target_type = NULL, array $target_bundles = [], $form_mode = 'default') {
if (is_null($target_type)) {
$target_type = $entity_type_id;
}
if (empty($target_bundles)) {
$target_bundles[$bundle] = $bundle;
}
$this
->createEntityReferenceField($entity_type_id, $bundle, $field_name, 'Reference field', $target_type, 'default', [
'target_bundles' => $target_bundles,
], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this
->assertTrue(TRUE, new FormattableMarkup('The field %field_name is created.', [
'%field_name' => $field_name,
]));
$this
->configureWidget($entity_type_id, $bundle, $field_name, $form_mode);
}