misd-service-development / phone-number-bundle

Integrates libphonenumber into your Symfony2-Symfony4 application
459 stars 143 forks source link

add number options option #211

Open webmasterMeyers opened 4 years ago

webmasterMeyers commented 4 years ago

pass options to the number input when using PhoneNumberType::WIDGET_COUNTRY_CHOICE
use like,

$builder->add('primaryContactPhone', PhoneNumberType::class, [
    'widget' => PhoneNumberType::WIDGET_COUNTRY_CHOICE,
    'country_choices' => $this->countryRepository->getCodes(),
    'preferred_country_choices' => [$options['countryCodes']],
    'number_options' => [
        'attr' => [
            'class' => 'js-phone-autocomplete',
            'data-autocomplete-url' => $this->router->generate('grid_api_contact_phone_get_matching'),
            'placeholder' => $this->phoneNumberUtil->getExampleNumber($options['countryCodes'])->getNationalNumber(),
        ],
    ],
])