- Issue created by @joehuggans
- 🇬🇧United Kingdom joehuggans Harrogate, UK
I have looked at how other elements in Drupal core handle this such as the Number field, and based on this, I propose changing the valueCallback to:
public static function valueCallback(&$element, mixed $input, FormStateInterface $form_state): mixed { if (!empty($input['full_number'])) { return $input['full_number']; } elseif (!empty($element['#default_value'])) { return $element['#default_value']; } return NULL; }
- Merge request !21Update PhoneInternationalElement.php to pass default_value → (Open) created by Unnamed author
- 🇬🇧United Kingdom joehuggans Harrogate, UK
Patch for anyone who needs this in the meantime.
- 🇬🇧United Kingdom joehuggans Harrogate, UK
My first suggestion wasn't working and was causing an error.
rather than using
!empty($input['full_number'])
, useisset($input['full_number'])
, otherwise the field will fallback to the default value if the field is left empty.