To alter the node ID field (nid) of our content view we add this to the file:
fields
CustomWidget.php
public static function isApplicable(FieldDefinitionInterface $field_definition) {
if (isset($field_definition->getDisplayOptions('form')['type'])) {
return $field_definition->getDisplayOptions('form')['type'] == 'slot_content_weights';
}
return FALSE;
}
13.11.2025 | Dominik Wille
Don't list a widget for a field type.
If this does not work...
broken_fapi_autocomplete.php
$form['nodes'] = [
'#title' => $this->t('Select articles'),
'#type' => 'entity_autocomplete',
'#target_type' => 'node',
'#tags' => TRUE,
'#selection_handler' => 'default',
'#selection_settings' => ['target_bundles' => ['article']],
'#default_value' => $default_nodes,
];...try adding an increased maxlength value:
fixed_fapi_autocomplete.php
$form['nodes'] = [
'#title' => $this->t('Select articles'),
'#type' => 'entity_autocomplete',
'#target_type' => 'node',
'#maxlength' => 1024,
'#tags' => TRUE,
'#selection_handler' => 'default',
'#selection_settings' => ['target_bundles' => ['article']],
'#default_value' => $default_nodes,
];
13.08.2026 | Pascal Crott
Can't save Form API autocomplete when referencing too many elements
my_module.module
$field_render_array = $entity->{$field_name}->view([
'type' => 'default_formatter', // Replace with desired formatter type.
'label' => 'hidden', // If you want to hide the label of the field (optional).
'settings' => [
'trim_length' => 100, // Example for textfields: Trim the text to 100 characters.
],
]);
12.12.2025 | Michael Ebert
Render field with given formatter type programmatically
EntityFieldValue.php
$raw_value = $entity->my_text_field->value;
echo $raw_value; // Outputs the raw dataEntityFieldProcessed.php
$processed_value = $entity->my_text_field->processed;
echo $processed_value; // Outputs the processed and safe-to-display data
05.03.2026 | Michael Ebert
How to output the processed value of a WYSIWYG text field
PasswordItem.php
/**
* Defines the 'password' entity field type.
*
* @FieldType(
* id = "password",
* label = @Translation("Password"),
* description = @Translation("An entity field containing a password value."),
* no_ui = TRUE,
* )
*/
18.12.2025 | Michael Böker