Fatal error with default value

Created on 18 February 2025, 2 months ago

I added an address field with country as default value to a content type. When I automatically create a node without an address field,

        $node = Node::create([
          'type' => 'article',
          'title' => 'test without address',
          'status' => 1, // Publish node.
        ]);

it creates an address field with country as default value. (it checks the default value before setting the value) but the node does not show because the address field is empty.

TypeError : Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given, called in C:\www\drupal\web\modules\contrib\address\src\Plugin\Field\FieldFormatter\AddressDefaultFormatter.php on line 162 dans Drupal\Component\Utility\Html::escape() (ligne 431 de C:\www\drupal\web\core\lib\Drupal\Component\Utility\Html.php).

To avoid fatal errors I suggest patching this before fixed the default country value.

🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇫🇷France lazzyvn paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024