Skip to content

Commit 6e000f9

Browse files
committed
Issue #2908571 by bojanz: ProfileSelect should validate that the default country is allowed
1 parent a3d594c commit 6e000f9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/order/src/Element/ProfileSelect.php

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ public static function processForm(array $element, FormStateInterface $form_stat
8585
if (!is_array($element['#available_countries'])) {
8686
throw new \InvalidArgumentException('The commerce_profile_select #available_countries property must be an array.');
8787
}
88+
// Make sure that the specified default country is available.
89+
if (!empty($element['#default_country']) && !empty($element['#available_countries'])) {
90+
if (!in_array($element['#default_country'], $element['#available_countries'])) {
91+
$element['#default_country'] = NULL;
92+
}
93+
}
8894

8995
$element['#profile'] = $element['#default_value'];
9096
$form_display = EntityFormDisplay::collectRenderDisplay($element['#profile'], 'default');

0 commit comments

Comments
 (0)