The document says Entity::create() takes

"$values (optional) An array of values to set, keyed by property name"

as an arguement.

I also found snippets like

$term = Term::create([
    'name' => $term_name,
    'vid' => $vocabulary_name,

and they worked.

But how exactly do you know what kind of values can be set in the array?
In the case above, where did people take the keys 'name' and 'vid' from?

2 Answers 2


If you look at the of baseFieldDefinitions method in class Term:

Here is a list of fields you can set in create Term:

  1. tid : Term ID
  2. uuid : The term UUID.
  3. vid: The vocabulary to which the term is assigned.
  4. langcode : The term language code.
  5. name : Name of term.
  6. description : description of term
  7. weight : weight of term.
  8. parent : Term parent.


$term = Term::create([
    'name' => 'term name',
    'vid' => 'tags',
    'status' => 1,
    'tid' => 13,
    'uuid' => 1,
    'langcode' => 'en',
    'description' => 'tags description',
    'weight' => -12,
    //'parent' => parent tid

Load an existing term

$term = Term::load(1);

or create an empty term to get the vocabulary specific bundle fields

$term = Term::create([
  'vid' => $vocabulary_name,

and dump it as an array:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.