Problem/Motivation

Notice: Undefined index: #preferred_countries in Drupal\phone_international\Element\PhoneInternationalElement::processInternationalPhone() (line 103 of modules/contrib/phone_international/src/Element/PhoneInternationalElement.php). 
Drupal\phone_international\Element\PhoneInternationalElement::processInternationalPhone(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 1007)
Drupal\Core\Form\FormBuilder->doBuildForm('my_details_form', Array, Object) (Line: 1070)
Drupal\Core\Form\FormBuilder->doBuildForm('my_details_form', Array, Object) (Line: 574)
Drupal\Core\Form\FormBuilder->processForm('my_details_form', Array, Object) (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm('\Drupal\module\Form\GuestMyDetailsForm', Object) (Line: 219)
Drupal\Core\Form\FormBuilder->getForm('\Drupal\module\Form\GuestMyDetailsForm', Array) (Line: 128)
...

Steps to reproduce

Use module

Proposed resolution

Change

        'data-exclude' => $element['#exclude'] ? implode("-", $element['#exclude_countries']) : [],
        'data-preferred' => $element['#preferred'] ? implode("-", $element['#preferred_countries']) : [],

to

        'data-exclude' => $element['#exclude'] ? implode("-", $element['#exclude']) : [],
        'data-preferred' => $element['#preferred'] ? implode("-", $element['#preferred']) : [], 
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ollie-db created an issue. See original summary.

shriaas’s picture

+1 for this, key names in getInfo() and processInternationalPhone() are different which creates this issue.
I will create an MR for this.

shriaas’s picture

Status: Active » Needs review
shriaas’s picture

The PhoneInternationalDefaultWidget is using #preferred_countries and #exclude_countries everywhere hence updated the name of properties in getInfo() method of PhoneInternationalElement class.

  • Shriaas committed b933fa1 on 3.x
    Issue #3277682 by ollie-db: Fix for  undefined index #...
saidatom’s picture

Status: Needs review » Fixed

@ollie-db & @Shriaas thanks for finding and fixing the error.

Status: Fixed » Closed (fixed)

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