Skip to content

Commit

Permalink
Render phone number input as tel(telephone) type
Browse files Browse the repository at this point in the history
  • Loading branch information
abdellahrk committed Dec 12, 2024
1 parent babf222 commit 0fae7fd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Form/Type/PhoneNumberType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Misd\PhoneNumberBundle\Form\DataTransformer\PhoneNumberToStringTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
Expand Down Expand Up @@ -99,16 +99,17 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$countryOptions['placeholder'] = $options['country_placeholder'];
}

$numberOptions = array_replace([
$telOptions = array_replace([
'error_bubbling' => true,
'required' => $options['required'],
'disabled' => $options['disabled'],
'translation_domain' => $options['translation_domain'],
'trim' => $options['trim'],
], $options['number_options']);

$builder
->add('country', ChoiceType::class, $countryOptions)
->add('number', TextType::class, $numberOptions)
->add('number', TelType::class, $telOptions)
->addViewTransformer(new PhoneNumberToArrayTransformer($transformerChoices));
} else {
$builder->addViewTransformer(
Expand Down

0 comments on commit 0fae7fd

Please sign in to comment.