$term = Term::load($_tid); $term->field_league_id = 'ID value'; $term->Save();
I am updating the terms by the code above but it's not working. Create the term by term->Save() is works normally. Everyone had experienced with that please help.
$term = Term::load($_tid); $term->field_league_id->setValue($league_id); $term->Save();
This solution is not working, it's throwing:
Call to a member function setValue() on a non-object in..
At the top, I declared ref. already.
The code for create new taxonomy is working fine, but not for updating.
$term = Term::create([ 'name' => $league->caption, 'vid' => 'league', 'field_league_id' => $league_id, 'field_league_code' => $league->league, 'field_league_year' => $league->year, 'field_league_numberofteams' => $league->numberOfTeams, ]); $term->Save();