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

Could not convert database value "0752086455" to Doctrine Type phone_number #232

Open
MiguelAdige opened this issue Jun 11, 2024 · 0 comments

Comments

@MiguelAdige
Copy link

Hello after installing the perfect bundle for the task I want to do. I get this error. Could not convert database value "" to Doctrine Type phone_number
I searched a bit and came across this discussion: https://github.com/misd-service-development/phone-number-bundle/issues/58
But this didn't solve my problem, can you help me?
thank

doctrine:
  dbal:
    types:
      phone_number: Misd\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType

in builder form :

use libphonenumber\PhoneNumberFormat;
use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType;
................................................................................................

->add('phone', PhoneNumberType::class, [
                'format' => PhoneNumberFormat::INTERNATIONAL,
                'widget' => PhoneNumberType::WIDGET_COUNTRY_CHOICE,
                'country_display_emoji_flag' => true,
                'country_placeholder' => $this->translate->trans('Choisisez l\'indicatif', domain: 'security'),
                'label' => $this->translate->trans("Téléphone portable", domain: 'security'),
                'row_attr' => ['class' => 'input-group mb-3'],
                'country_options' => [
                    'autocomplete' => true,
                ],
            ]);

twig :

       {{ form_start(form) }}
       {{ form_row(form.firstname) }}
       {{ form_row(form.lastname) }}
       {{ form_row(form.phone) }}
        <button class="btn btn-primary w-100 py-2" type="submit">{% trans %}Sauvegarder{% endtrans %}</button>
       {{ form_end(form) }}

entity :

#[PhoneNumber(regionPath: 'countryPhone', format: PhoneNumberFormat::INTERNATIONAL, type: PhoneNumber::MOBILE)]
#[ORM\Column(length: 35, nullable: true, type: PhoneNumberType::NAME)]
private ?string $phone = null;
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