There are a couple of problems when using this field with more than one value.
* If the field is set to required and only one country is selected in the field settings you do not have a country selector and there's no way of removing one field value.
* If the field is set to required and also one of the address fields is also required (e.g. city) then you cannot save the content, because every time you try to edit the content again, there will be another field value added which cannot be removed, but since one of the sub-fields is required, you are stuck.
* If the field is not required or you specified more than one country in the field settings, it is possible to remove one field value. However that is not very straight forward: only after trial and error I found out that you need to set the country to none but when you do that there is a little select where you do not know what to do with it (looks like a weight selector).
See attached images


| Comment | File | Size | Author |
|---|---|---|---|
| #13 | address-multiple_value-2723917-13.patch | 8.41 KB | enriquelacoma |
| #11 | interdiff_10-11.txt | 5.86 KB | enriquelacoma |
| #11 | address-multiple_value-2723917-11.patch | 8.16 KB | enriquelacoma |
| #10 | address-multiple_value-2723917-10.patch | 9.67 KB | enriquelacoma |
| Edit_Client_Request_02.png | 46.59 KB | pixelmord |
Comments
Comment #2
pixelmord commentedComment #3
bojanz commentedThanks for documenting this. We haven't really optimized for this use case, since it's hard to distinguish multiple addresses semantically (that's why we do some kind of entity above, that can tell us what the purpose of the address is). I'll make sure to address it in the upcoming months.
Comment #4
tamarpe commentedSame issue here. On update/creating nodes, the country is set and the node can't be saved/updated because of the required fields..
Comment #5
frederickjhHi All!
I ran into this too. The fix for having to to set the empty field to none when the node is edited is: to go into Manage Form Display then find your Address field and set the country to none. That way when a user edits the node they will not need to go and change the country to none to save.
Comment #6
imclean commentedObviously this is still an issue. It can make sense to lock a user to a specific country and make at least one address required. Not being able to remove the empty additional address means the content can't be edited.
Comment #7
nickgee commentedHi there, I just want to share the work-around that I came up with, which I think will suffice our needs (pending user testing).
In our case, we needed at least one `proponent` address, and they were most likely going to be in Canada.
Step 1: I removed any required fields from the GUI and I removed any Country requirements as well.
Step 2: I added the following to mymodule_form_alter():
The above solution allows us to have a the first field required and set to a Canadian address for a better UX. Adding additional `proponents` is not as smooth an experience and we can't require them but this allows us to add and remove field values and allows us to save the form.
Comment #8
bojanz commentedRetitling, reclassifying. This is not something we've ever supported (D7 or D8), but there's no reason not to.
Marked #3005487: Address field + unlimited values causes node/add form to have 5 address fieldsets as duplicate.
Comment #9
gbirch commented+1 for adding support for this. Our use case: database of health care practices, many of which have multiple office locations. Client wants to be able to search by practice characteristics (which we do NOT want to duplicate), and also to see where their offices are.
Comment #10
enriquelacoma commentedThis happens because, when the field is set as required, all country fields are set as required. This patch checks the cardinality of the field and sets as required only the first one, this way it, when using a cardinality above 1, all additional instances are not required.
Comment #11
enriquelacoma commentedI did some refactoring to the test, so it is clearer.
Comment #12
joevagyok commentedI tested the patch functionally and it works fine. Good job.
However, it needs some improvement on readability and some minor things. I will give you more specific list of comments in PM.
Comment #13
enriquelacoma commentedI updated the patch to improve comments and make the code more readable.
Comment #14
enriquelacoma commentedComment #15
joevagyok commentedThank you @enriquelacoma. The patch looks good, tested locally and it works.
Comment #16
sabina.h commentedI've tested the patch from #13 and it works.
Comment #17
ar_howard commentedPatch#13 worked for me.
Comment #18
damienmckennaGood work on the test coverage!
Comment #20
jsacksick commentedCommitted! Thanks @enriquelacoma!