Skip to main content
added 470 characters in body
Source Link
Maouna
  • 1.2k
  • 8
  • 11

Field entities can be created via FieldConfig::create($values).

For example, in the UserRegistrationTest of core, a 'user_picture' field is added to the user entity like this:

$field_storage = FieldStorageConfig::create([
  'field_name' => 'user_picture',
  'entity_type' => 'user',
  'type' => 'image',
]);
$field_storage->save();

$field = FieldConfig::create([
  'field_name' => 'user_picture',
  'entity_type' => 'user',
  'bundle' => 'user',
]);
$field->save();

Field entities can be created via FieldConfig::create($values).

Field entities can be created via FieldConfig::create($values).

For example, in the UserRegistrationTest of core, a 'user_picture' field is added to the user entity like this:

$field_storage = FieldStorageConfig::create([
  'field_name' => 'user_picture',
  'entity_type' => 'user',
  'type' => 'image',
]);
$field_storage->save();

$field = FieldConfig::create([
  'field_name' => 'user_picture',
  'entity_type' => 'user',
  'bundle' => 'user',
]);
$field->save();
Source Link
Maouna
  • 1.2k
  • 8
  • 11

Field entities can be created via FieldConfig::create($values).