odolbeau / phone-number-bundle

Integrates libphonenumber into your Symfony application
MIT License
217 stars 43 forks source link

Symfony 6.3 error: Variable "widget" does not exist. #151

Closed redflo closed 1 year ago

redflo commented 1 year ago

Hi, i try to use the Form with Symfony 6.3.0 and bootstrap 5, but i get the error, even if i have a "widget" in the options field.

Code:

namespace App\Form;

use libphonenumber\PhoneNumberFormat;
use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType as MisdPhoneNumberType;
use App\Entity\PhoneNumber;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;

class PhoneNumberType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('number', \Misd\PhoneNumberBundle\Form\Type\PhoneNumberType::class, [
                'widget' => \Misd\PhoneNumberBundle\Form\Type\PhoneNumberType::WIDGET_COUNTRY_CHOICE,
                'country_choices' => ['GB', 'JE', 'FR', 'US'],
                'preferred_country_choices' => ['GB', 'JE']
                //'widget' => MisdPhoneNumberType::WIDGET_SINGLE_TEXT, 
                //'default_region' => 'DE', 
                //'format' => PhoneNumberFormat::NATIONAL
                ])

And I get the error:

Uncaught PHP Exception Twig\Error\RuntimeError: "Variable "widget" does not exist." at /project/vendor/odolbeau/phone-number-bundle/src/Resources/views/Form/phone_number_bootstrap_5.html.twig line 2

{
    "exception": {}
}

What is wrong?

maxhelias commented 1 year ago

Can you publish a reproduce pls ? That way it will be quicker for me to see what's wrong.

redflo commented 1 year ago

3 months later, i am unable to reproduce the issue. Probably i created some nasty bugs since i was learning symfony at this time.