newism / craft3-fields

Address, telephone, email, embed and gender fields for CraftCMS 3.x
Other
54 stars 16 forks source link

Undefined index: countryCode #9

Closed mikestecker closed 6 years ago

mikestecker commented 7 years ago

When adding a phone number field and deselecting the Show country selector checkbox. I am presented with an error Undefined index: countryCode when saving an entry.

in vendor/newism/craft3-fields/src/fields/Telephone.php at line 131

return new TelephoneModel($value['countryCode'], $value['rawInput']);

Edit: I had a look in my database to see how the field settings are stored. They give me this:

{"showCountrySelector":false,"defaultCountryCode":"US"}
leevigraham commented 7 years ago

@mikestecker, Thanks for the report. I'll take a look. Which version of Craft3 are you running?

mikestecker commented 7 years ago

@leevigraham I'm running the latest beta which is 26 I believe.

mikestecker commented 6 years ago

@leevigraham hey just wanted to follow up on this. I'm on beta 34 now and the problem is still happening.

leevigraham commented 6 years ago

@mikestecker, Whats in your entryversions table for the entry? Can you paste the value of the data column?

mikestecker commented 6 years ago

@leevigraham sorry for the delay... I just made it so it always show the country code dropdown at all times to get around the issue for now. Here's the relevant part of one of my entryversions tables:

"108":{"countryCode":"US","rawInput":"765-662-9931","phoneNumber":[]}

leevigraham commented 6 years ago

@mikestecker … finally getting some time to look at this. I think in more recent versions I've removed the option to hide the drop down. Which version are you currently running?

mikestecker commented 6 years ago

@leevigraham I'm running your latest version so that issue has gone away now. It would be nice to be able to set a default country though so the user doesn't have to select it each time.

leevigraham commented 6 years ago

It would be nice to be able to set a default country though so the user doesn't have to select it each time.

I agree… I'll add it back in a future version and make sure it works properly this time :)