Skip to content

Commit

Permalink
Issue #2908571 by bojanz: ProfileSelect should validate that the defa…
Browse files Browse the repository at this point in the history
…ult country is allowed
  • Loading branch information
bojanz committed Sep 13, 2017
1 parent a3d594c commit 6e000f9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/order/src/Element/ProfileSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ public static function processForm(array $element, FormStateInterface $form_stat
if (!is_array($element['#available_countries'])) {
throw new \InvalidArgumentException('The commerce_profile_select #available_countries property must be an array.');
}
// Make sure that the specified default country is available.
if (!empty($element['#default_country']) && !empty($element['#available_countries'])) {
if (!in_array($element['#default_country'], $element['#available_countries'])) {
$element['#default_country'] = NULL;
}
}

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

0 comments on commit 6e000f9

Please sign in to comment.