Set the default value for country to US for Advanced Address elements, none are set on webform.
Tried also setting all default values and not just country such as street, city, zip and the default values still do not show on the webform.

Comments

vivify created an issue. See original summary.

jrockowitz’s picture

StatusFileSize
new3.78 KB

The attached webform replicates this issue.

jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new481 bytes

Great catch!!!

The issue is that the #default_value is being stored as a string and not an associative array.

  • jrockowitz committed 95d77fb on 8.x-5.x
    Issue #2992893 by jrockowitz, vivify: Advanced Address Default Value Not...
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Mile3’s picture

Defaults don't seem to be working for Advanced Address. I've tried with the Set Defaults option, but no dice.

jrockowitz’s picture

I am not able to replicate any issues with the address element's default values. @see attached webform

weseze’s picture

Any progress on this? Tested with 5.15 and it is still an issue.
How can I help fix this?

jrockowitz’s picture

Are you able to replicate this issue using the example webform from #8? If not, can you please provide an example webform.

weseze’s picture

I think the issue might be that I assumed it would work with tokens instead of fixed values.

I tried:

field_adres:
  '#type': address
  '#title': Adres
  '#default_value': '[webform_submission:user:field_adres]'

But that dit not populate the field with my user data.

And also tried

field_adres:
  '#type': address
  '#title': Adres
  '#default_value':
    country_code: '[webform_submission:user:field_adres:country_code]'
    langcode: '[webform_submission:user:field_adres:langcode]'
    given_name: '[webform_submission:user:field_adres:given_name]'
    family_name: '[webform_submission:user:field_adres:family_name]'
    organization: '[webform_submission:user:field_adres:organization]'
    address_line1: '[webform_submission:user:field_adres:address_line1]'
    address_line2: '[webform_submission:user:field_adres:address_line2]'
    locality: '[webform_submission:user:field_adres:locality]'
    administrative_area: '[webform_submission:user:field_adres:administrative_area]'
    postal_code: '[webform_submission:user:field_adres:postal_code]'
    additional_name: '[webform_submission:user:field_adres:additional_name]'
    sorting_code: '[webform_submission:user:field_adres:sorting_code]'
    dependent_locality: '[webform_submission:user:field_adres:dependent_locality]'

But that fails to save correctly.

jrockowitz’s picture

But that fails to save correctly.

What error message is displayed?

weseze’s picture

Hmmm, no idea what I'm doing different, but it seems to work just fine now...