05.03.2026 | Michael Ebert

How to output the processed value of a WYSIWYG text field

EntityFieldValue.php
$raw_value = $entity->my_text_field->value;
echo $raw_value;  // Outputs the raw data
EntityFieldProcessed.php
$processed_value = $entity->my_text_field->processed;
echo $processed_value;  // Outputs the processed and safe-to-display data

Issue:

You need to output the processed value of a WYSIWYG text field to the user.

Solution:

For text fields there is a nice property that gives you the processed value directly. Let's have a quick look at the differences:

 unprocessed (raw) outputprocessed output
Field property->value->processed
When to Use
  • when you need the original, unaltered data.
  • when you plan to apply custom processing or formatting.
  • for programmatic manipulation or calculations that require raw data.
  • When displaying the field value directly to users.
  • when you need a value that has been filtered or formatted according to site settings (e.g., text formats, HTML filtering).
  • to ensure consistency in how field data is presented across the site.

CAUTION: The field property 'processed' only exists on WYSIWYG textfields!

Weitere DevBits

30.07.2026 | Lothar Ferreira Neumann

Merge multidimensional arrays in Drupal

nested_array_merge_deep.php
use Drupal\Component\Utility\NestedArray;

// Parent array with default settings.
$parent_array = [
    'config' => [
        'theme' => 'dark',
        'layout' => [
            'width' => 800,
            'height' => 600,
        ],
    ],
];

// Child array adds more nested data but doesn't override existing values.
$child_array = [
    'config' => [
        'layout' => [
            'depth' => 300, // New nested key
        ],
        'features' => [
            'animations' => true, // New section
        ],
    ],
];

// Merge both arrays.
$merged_array = NestedArray::mergeDeep($parent_array, $child_array);
nested_array_result.php
[
    'config' => [
        // Unchanged (not overridden)
        'theme' => 'dark', 
        'layout' => [
            // Keeps parent value
            'width' => 800, 
            // Keeps parent value  
            'height' => 600,
            // New nested key added
            'depth' => 300,   
        ],
        'features' => [
            // New section added
            'animations' => true, 
        ],
    ],
]
php
array manipulation
arrays
drupal
12.12.2025 | Pascal Crott

Sort blocks inside layout regions by weight.

my_theme.theme
/**
 * Implements hook_preprocess_HOOK() for layout.html.twig.
 */
function hook_preprocess_layout(&$variables) {
  $layout = $variables['layout'];
  foreach ($layout->getRegionNames() as $region_name) {
    if (array_key_exists($region_name, $variables['content'])) {
      uasort($variables['content'][$region_name], [\Drupal\Component\Utility\SortArray::class, 'sortByWeightProperty']);
    }
  }
}
drupal
php
theme
Layout Builder
copy-paste