Problem/Motivation
Every contact should have a mail field.
We also want to test a concept we intended to introduce more widely: a multivalue field with predicated type
Proposed resolution
We will introduce a new field type "mail with type".
The new type will subclass the mail field and add a new type base field.
"type" is a string
Allowed type values are for now hardcoded. Might be switched later to some configurable definition.
A multivalue field instance is added to the contact by default. (will be a follow-up)
The widget will offer the type selection (drop down), for now just offer "home" and "work".
Make sure the field also displays.
As a followup, make our collect_demo case build on top of this.
#2703967: Show email field in Collect CRM
User interface changes
A new field type "mail with type".
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff.txt | 1.27 KB | slashrsm |
#13 | 2704451_13.patch | 18.51 KB | slashrsm |
#11 | interdiff.txt | 20.25 KB | slashrsm |
#11 | 2704451_11.patch | 18.66 KB | slashrsm |
#10 | add_a_mail_with_type-2704451-10-interdiff.txt | 2.79 KB | mbovan |
Comments
Comment #2
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedThis can be done after #2708029: Rename "Contact" entity type to "Individual", #2708047: Add base fields to the "Individual" entity type
Comment #3
miro_dietikerAgree that providing the configuration is possibly not worth, but you can still start coding the field type, widget, formatter meanwhile.
Also attaching the field to a different entity type as a cleanup isn't that much duplicate work.
This is a prototype issue that will unlock many others. We want to start with this ASAP.
Comment #4
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedWe can start working on the field type and add it to the entity in a follow-up.
Comment #5
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedAttaching an initial patch with 'mail_with_type' field type, widget, formatter, schemas and tests.
Not sure about naming... It will need some cleanup in configuration settings too.
Comment #6
miro_dietikerWhere are we placing an API to fetch a / the first value of a specific type?
Comment #7
BerdirI think such an API would basically be a replacement for getPrimaryField(), so on the entities that use it? Anything else doesn't give you method autocomplete.
Comment #8
Berdirwe will also need schema for the field config settings and the field value
Should we display it like \Drupal\Core\Field\Plugin\Field\FieldFormatter\MailToFormatter maybe? Or support both..
We need to define what we actually store? Do we support both pre-defined and and other labels? Or only pre-defined (would be a lot easier for storage, we can make it a 32 character ascii string)
Comment #9
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedAdded description for "Mail types".
Ha, didn't see #8 before uploading.
Comment #10
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedAddressed #8.1, #8.2 and schema settings for #8.3.
Comment #11
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedChanges on top of #10:
- renamed field/formatter/widget s/mail/email to be consistent with core
- made mail types list configurable
- slightly modified formatter's output
- improved test coverage
Comment #12
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedLooks like these are not used.
indentation.
Other than that looks good.
Comment #13
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedFixed.
Comment #14
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedLooks good to go.
Comment #16
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedCommitted.
Comment #17
Andreas Radloff CreditAttribution: Andreas Radloff commentedI'm a little late to the party, but I just wanted to point out that there is already a D8 version of Double Field which allows creating key-value fields. Maybe that could be useful for the social profiles and such?
Double field does not support an email field out of the box.