- Issue created by @bgilhome
- 🇫🇷France pcharrat La rue, la vraie.
The patch works because when I get the following code:
/** * Implements hook_field_create_definitions(). */ function mymodule_list_field_create_definitions_alter(array &$definitions) { // Define your fields here by entity type. $definitions['node'] = [ 'demo_field_2' => [ 'name' => 'demo_field_2', 'label' => 'This is my field', 'type' => 'string', 'force' => FALSE, 'bundles' => [ 'page' => [ 'default_value' => ['Lorem Ipsum'], ], ], ], ]; }
I see that I have my default value
- 🇫🇷France pcharrat La rue, la vraie.
I think we can add a default value for the field info.
So, I propose the following patch.
A test code :/** * Implements hook_field_create_definitions(). */ function contrib_todo_list_field_create_definitions_alter(array &$definitions) { // Define your fields here by entity type. $definitions['node'] = [ 'demo_field' => [ 'name' => 'demo_field', 'label' => 'This is my field', 'type' => 'string', 'default_value' => ['This is my default value'], 'force' => FALSE, 'bundles' => [ 'page' => [ 'default_value' => ['This is a more specific value'], ], 'article' => [] ], ], ]; }
This is my result :
Default value article :
Default value page :