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' => 1000,
'name' => 'Lausanne',
'lat' => '47.3879577',
'lng' => '8.044136',
];
$term = Term::create([
'name' => $city['zip'].' '.$city['name'],
'vid' => 'cities',
'field_cities_zip_city' => [
'postal_code' => $city['zip'],
'locality' => $city['name'],
],
'field_cities_coordinates' => [
'lat' => $city['lat'],
'lng' => $city['lng'],
],
]);
$term->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' => 1000,
'name' => 'Lausanne',
'lat' => '47.3879577',
'lng' => '8.044136',
];
$term = Term::create([
'name' => $city['zip'].' '.$city['name'],
'vid' => 'cities',
'field_cities_zip_city' => [
'postal_code' => $city['zip'],
'locality' => $city['name'],
],
'field_cities_coordinates' => [
'lat' => $city['lat'],
'lng' => $city['lng'],
],
]);
//set the fields again manually, but this has no effect
$term->field_cities_zip_city->postal_code = $city['zip'];
$term->field_cities_zip_city->locality = $city['name'];
$term->save();
The address fields are still empty. What am I missing?? Thanks in advance for any help!
$city['plz']
which doesn't appear to be defined.