I am trying to save data programmatically to an address field from the Address module.
I am not successful.
First, when I dsm() a node with the address field filled out, it looks like this:
[field_addr] => Array
(
[x-default] => Array
(
[0] => Array
(
[langcode] =>
[country_code] => US
[administrative_area] => CA
[locality] => San Diego
[dependent_locality] =>
[postal_code] => 91945
[sorting_code] =>
[address_line1] => 123 main st
[address_line2] => apt 2
[organization] =>
[given_name] =>
[additional_name] =>
[family_name] =>
)
)
)
However, no matter how I try to save it to my node, it doesn't work.
I create an array that looks like this:
Array
(
[x-default] => Array
(
[0] => Array
(
[address_line1] => Australian Club
[address_line2] => Royal Lane
[locality] => Sydney
[administrative_area] => NSW
[country] => Australia
)
)
)
Let's say with the name, $address_save
And then do the following:
$node->set('field_addr', $address_save);
No luck. My node saves with other fields, but this one doesn't. I've also tried it without the x-default key around it as well as without a delta, but neither of those work either.
How can I save values to an Address field inside of a node?