Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Form/Type/PhoneNumberType.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
if (false === isset($countries[$region])) {
continue;
}

if (null !== $options['country_widget_label'] && is_callable($options['country_widget_label'])) {
$countryChoices[$options['country_widget_label']($countries, $name, $region)] = $region;
} else {
$countryChoices[sprintf('%s (+%s)', $name, $countries[$region])] = $region;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbuh Is a default sprintf() call okay, in order to get rid off the else branch?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would you place that sprintf() call?


$countryChoices[sprintf('%s (+%s)', $name, $countries[$region])] = $region;
}

$transformerChoices = array_values($countryChoices);

$countryOptions = $numberOptions = array(
Expand Down Expand Up @@ -141,6 +145,7 @@ public function configureOptions(OptionsResolver $resolver)
'by_reference' => false,
'error_bubbling' => false,
'country_choices' => array(),
'country_widget_label' => null,
'preferred_country_choices' => array(),
)
);
Expand Down