Can't programmatically fill address field on taxonomy term creation I'm creating some taxonomy terms inside of an update hook and they have a coordinates field and an address field containing only zipcode and locality.

The Vocabulary is called cities, the address field is called field_cities_zip_city and the coordinates are called field_cities_coordinates.

//the exact data that fails
$city = [
  'zip' =&gt; 1000,
  'name' =&gt; 'Lausanne',
  'lat' =&gt; '47.3879577',
  'lng' =&gt; '8.044136',
];


$term = Term::create([
  'name' =&gt; $city['zip'].' '.$city['name'],
  'vid' =&gt; 'cities',
  'field_cities_zip_city' =&gt; [
    'postal_code' =&gt; $city['zip'],
    'locality' =&gt; $city['name'],
  ],
  'field_cities_coordinates' =&gt; [
    'lat' =&gt; $city['lat'],
    'lng' =&gt; $city['lng'],
  ],
]);
$term-&gt;save();


What happens is, the term gets created, the coordinates get filled in properly, but the address remains empty despite even being required fields.

Trying like this did not change anything:

//the exact data that fails
$city = [
  'zip' =&gt; 1000,
  'name' =&gt; 'Lausanne',
  'lat' =&gt; '47.3879577',
  'lng' =&gt; '8.044136',
];


$term = Term::create([
  'name' =&gt; $city['zip'].' '.$city['name'],
  'vid' =&gt; 'cities',
  'field_cities_zip_city' =&gt; [
    'postal_code' =&gt; $city['zip'],
    'locality' =&gt; $city['name'],
  ],
  'field_cities_coordinates' =&gt; [
    'lat' =&gt; $city['lat'],
    'lng' =&gt; $city['lng'],
  ],
]);

//set the fields again manually, but this has no effect
$term-&gt;field_cities_zip_city-&gt;postal_code = $city['zip'];
$term-&gt;field_cities_zip_city-&gt;locality = $city['name'];

$term-&gt;save();


The address fields are still empty. What am I missing??
Thanks in advance for any help!
You need to provide the country_code to your address field.

like 

$city = [
  'zip' =&gt; 1000,
  'name' =&gt; 'Lausanne',
  'lat' =&gt; '47.3879577',
  'lng' =&gt; '8.044136',
];


$term = Term::create([
  'name' =&gt; $city['zip'].' '.$city['name'],
  'vid' =&gt; 'cities',
  'field_cities_zip_city' =&gt; [
    'country_code' =&gt; 'CH',  // country code is required
    'postal_code' =&gt; $city['zip'],
    'locality' =&gt; $city['name'],
  ],
]);
$term-&gt;save();