for ($delta = 0;
$delta <
$this->fieldTestData->field_storage->
getCardinality();
$delta++
) { // field_test_widget uses 'textfield'
$this->
assertEquals('textfield',
$form[$this->fieldTestData->field_name
]['widget'
][$delta]['value'
]['#type'
], "First field's form delta {
$delta} widget is textfield"
);
} for ($delta = 0;
$delta <
$this->fieldTestData->field_storage_2->
getCardinality();
$delta++
) { // field_test_widget uses 'textfield'
$this->
assertEquals('textfield',
$form[$this->fieldTestData->field_name_2
]['widget'
][$delta]['value'
]['#type'
], "Second field's form delta {
$delta} widget is textfield"
);
} // Test generating widgets for all fields.
$display =
$display_repository->
getFormDisplay($entity_type,
$this->fieldTestData->field->
getTargetBundle());
foreach ($display->
getComponents() as $name =>
$options) { if ($name !=
$this->fieldTestData->field_name_2
) { $display->
removeComponent($name);
} } $form =
[];
$form_state =
new FormState();
$display->
buildForm($entity,
$form,
$form_state);
$this->
assertFalse(isset($form[$this->fieldTestData->field_name
]), 'The first field does not exist in the form'
);
$this->
assertEquals($this->fieldTestData->field_2->
getLabel(),
$form[$this->fieldTestData->field_name_2
]['widget'
]['#title'
], "Second field's form title is {
$this->fieldTestData->field_2->
getLabel()}"
);
for ($delta = 0;
$delta <
$this->fieldTestData->field_storage_2->
getCardinality();
$delta++
) {