I just noticed when you create a new node, it will still save a record in the field's data table if any addressfield country defaults are set to anything other than "-None-"
So even if you set the default country to 'US' and then create a new node and change the country from 'US' to -None-, it will still save a record in the database showing US. If I then edit that node and set the country to -None-, it will correctly remove the row from the database. Very strange...
If there is a row in the database with just the Country set, it will cause Panels to output a label with a blank address on the node view.
If the addressfield default country is set to -None- and you create a new node, then everything works correctly. It doesn't save a record in the database.
Let me know if you need any additional information.
Comments
Comment #1
bojanz commentedConfirmed.
Oddly enough, if I edit the node, the default country is shown instead of "None", but if I set it to "None" this time, the save is correct, and the row disappears from the database. So it appears this bug is limited to the add form.
EDIT: This is coming from core:
However, according to the docblock, it should not trigger for users who intentionally chose the empty value.
Still, I can confirm it fires.
I'm not sure how to proceed, will need to sleep on it.
Comment #2
bojanz commentedConfirmed to be a core bug: #1253820: It's impossible to submit no value for a field that has a default value.
The issue lists a workaround which I will try to implement tomorrow.
Comment #3
gmclelland commentedWow! your fast. Thanks for confirming, I'm glad it wasn't just me.
Comment #4
bojanz commentedI have confirmed that there is no fix for this, no workaround works for all cases.
My current thinking is to remove the "default values" fieldset completely, replace it with a "Default country" dropdown, and ask people to provide other defaults via plugins.
In progress...
Comment #5
bojanz commentedPlan created: #2392863: Remove the default values instance setting, introduce a default country instance setting #2392855: Provide a hook for altering address defaults