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

My form submission is always invalid #198

Open
Evertt opened this issue Apr 23, 2019 · 3 comments
Open

My form submission is always invalid #198

Evertt opened this issue Apr 23, 2019 · 3 comments

Comments

@Evertt
Copy link

Evertt commented Apr 23, 2019

I have an entity that uses the phone number type:

/**
 * @ORM\Column(type="phone_number")
 * @AssertPhoneNumber
 */
private $phone;

I have a form that uses the phone number type:

->add('phone', PhoneNumberType::class)

But when I submit the form, it's always invalid. And I think it's because when I type in something like +31612345678 (which is a valid phone number) then it transforms that into the text Country Code: 31 National Number: 612345678 before passing it to the validator.

That's gotta be a bug, right? Please help. 🙏

@Evertt
Copy link
Author

Evertt commented Apr 23, 2019

Sorry, my mistake. I still had these functions in my entity

public function getPhone(): ?string
{
    return $this->phone;
}

public function setPhone(string $phone): self
{
    $this->phone = $phone;

     return $this;
}

which converted the phone number to string...

@Evertt Evertt closed this as completed Apr 23, 2019
@Evertt
Copy link
Author

Evertt commented Apr 23, 2019

Hmm, something is still not right. Right now it seems to work properly when I try to validate Dutch phone numbers, but when I try to validate Nigerian phone numbers it still doesn't work. And our app is actually made for Nigerians.

Have any of you ever tried to validate Nigerian phone numbers and tried if it worked?

@Evertt Evertt reopened this Apr 23, 2019
@BThiebaut
Copy link

Hi, I also have a lot of problems with the validation using ethiopian numbers or other with 3 numbers on the indicator. For now I solve it by overriding the Validator to make it more flexible, but for long terms it's not viable.

I will consider moving on another repo like https://github.com/odolbeau/phone-number-bundle , this one seems not to be maintained anymore.

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

2 participants