danvick / form_builder_phone_field

MIT License
8 stars 25 forks source link

Better tutorial / example needed: How to save and load (display) data #9

Open rainerlonau opened 3 years ago

rainerlonau commented 3 years ago

Hi there, I´m using firestore to save the data from my registration form. What´s the best way to get and save data from the FormBuilderPhoneField and then load and display it again. I´m using

onChanged: (value) {
  _user.phone = value;
}

to save the value from the FormBuilderPhoneField. But this is the complete number, e.g. +491621234567. This is saved into the database and I guess this is wrong already. Because I would need the countrycode (+49 is for Germany, which is 'DE') and the phone numeber, in this case 1621234567. With these two values I could then set the defaultSelectedCountryIsoCode to 'DE' and show only the number '1621234567' in _textEditingControllerPhone.text.

But right now I get the full number, save that and when I open the settings page in my app the FormBuilderPhoneField shows +49 +491621234567 How do I get the countrycode? How do you save the data? Thanks