0

I'm trying to create a term programmatically:

$term = Term::create([
  'vid' => 'vocabulary_mane',
  'name' => 'term_name',
]);

$term->save();

I can see my term in my overview page in the back-end:

Overview page


But when I click on modify, I will receive an error page:

Error page


In the journal this is the log:

Error log


What is wrong?

0

i found the solution.

the problem was with uppercase/lowercase vid value.

If your vocabulary starts with an uppercase letter ex: 'Animal', thr vid value will starts with a lowercase letter ex: 'animal' otherwise you will have an error

This was my problem, hope it will you help.

  • Machine names are always lowercase. You used to have to set a parent hierarchy value before in 7.x, not sure if that still applies here. – Kevin Nov 21 '17 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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