how to update an existing address field on a profile ?

Created on 21 June 2024, 8 days ago

Problem/Motivation

When i run the following code i get "bad gateway " with no error message. with xdebug everything looks fine until i get to the ->save line and then it crashes. is this code correct to update the address field?

$profile_id = 29604; 
  $profile_object = Profile::load($profile_id);
  $field_city = $profile_object->get('field_city')->value;
  $field_state = $profile_object->get('field_state')->value;
  $field_postal_code = $profile_object->get('field_postal_code')->value;
  $addresses = $profile_object->get('field_address');
  $addresses->setValue(array(
        'country_code' => 'US',
        'locality' => $field_city,
        'postal_code' => $field_postal_code,
        'administrative_area' => $field_state
    ));
    $profile_object->save($profile_object);

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dianacastillo Miami

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024