Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

short country name #97

Open
thoroc opened this issue Jun 26, 2016 · 2 comments
Open

short country name #97

thoroc opened this issue Jun 26, 2016 · 2 comments

Comments

@thoroc
Copy link

thoroc commented Jun 26, 2016

Hi,

I couldn't find it in the docs: How do I display the country code and identification in the drop down when choosing a widget 'country_choice' ?

I know this could be changed in the Misd\PhoneNumberBundle\Form\Type\PhoneNumberType at line 68 as follow:

    foreach (Intl::getRegionBundle()->getCountryNames() as $region => $name) {
        if (false === isset($countries[$region])) {
            continue;
        }
        $countryChoices[sprintf('%s (+%s)', $region, $countries[$region])] = $region;
    }

But I was wondering if there isn't a cleaner way to do this

~thoroc

@thoroc
Copy link
Author

thoroc commented Jun 28, 2016

This could be solved by merging the following PR: #90

@thoroc
Copy link
Author

thoroc commented Jul 4, 2016

for ref, once the PR is merged, the label can be used as follow:

$builder
    ->add('telephoneNumber', PhoneNumberType::class, [
        'widget'                    => PhoneNumberType::WIDGET_COUNTRY_CHOICE,
        'country_choices'           => ['DE', 'CH', 'AT'],
        'country_widget_label'      => function($countries, $name, $region){
            return sprintf('%s (+%s)', $region, $countries[$region]);
        },
        'preferred_country_choices' => ['DE'],
        ...
    ])
;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant