diff --git a/tailbone/forms/fields.py b/tailbone/forms/fields.py index c052745a..17ea4d45 100644 --- a/tailbone/forms/fields.py +++ b/tailbone/forms/fields.py @@ -72,9 +72,12 @@ class DefaultEmailField(fa.Field): address = self._deserialize() contact = self.parent.model if contact.emails: - email = contact.emails[0] - email.address = address - else: + if address: + email = contact.emails[0] + email.address = address + else: + contact.emails.pop(0) + elif address: email = contact.add_email_address(address) @@ -96,7 +99,10 @@ class DefaultPhoneField(fa.Field): number = self._deserialize() contact = self.parent.model if contact.phones: - phone = contact.phones[0] - phone.number = number - else: + if number: + phone = contact.phones[0] + phone.number = number + else: + contact.phones.pop(0) + elif number: phone = contact.add_phone_number(number)