- 🇵🇱Poland Bartosz Pijet
use Drupal\profile\Entity\Profile; $profile = Profile::load(123123); $addresses = $profile->get('address'); $addresses->setValue(array( 'langcode' => 'pl', 'country_code' => 'PL', 'locality' => 'Gniezno', 'postal_code' => '11-500', 'address_line1' => 'Nieznana', 'address_line2' => '17/28', 'given_name' => 'Piotr', 'family_name' => 'Kowalski', )); $profile->save(); // Debug print so you can validate that it is working. ksm($profile->get('address'));
- 🇨🇦Canada liquidcms
Not entirely sure I get what you are doing; but i think its exactly what I don't want to do.
Should be something like this:
$profile = Profile::load(123123); $address1 = $profile->get('address'); $profile->set('field_address2', $address1); $profile->save();
- 🇬🇧United Kingdom dahousecat
This should do it:
$profile = Profile::load(123123); $address1 = $profile->get('address'); $profile->set('field_address2', $address1->first()->getValue()); $profile->save();
Of course if this is multi cardinality replace first() with a loop.