Hi everyone,
I’m trying to create a new entry but I have a problem with a location type field.
How can I set this field through setField() method?
I tried an array but it failed.
Thanks!
Hi everyone,
I’m trying to create a new entry but I have a problem with a location type field.
How can I set this field through setField() method?
I tried an array but it failed.
Thanks!
Could you try:
$entry->setField('coordinates', 'en-US', new \Contentful\Core\Api\Location($latitude, $longitude));
Thank you for your response Alma. I had forgot to include the array keys ‘lat’ and ‘lon’, so I have used an array instead a Location object.
This is my implementation:
$coordinates = [
‘lat’ => $hotel->coordinates()->latitude(),
‘lon’ => $hotel->coordinates()->longitude()
];
$entry->setField(‘coordinates’, ‘en-US’, $coordinates);