Currently, a field's default value is locked once data has been entered.
Here is why this is going to be a total WTF for users:
Suppose we add a filefield to a user. This is basically the user picture feature from D6.
We add a default image for users who don't supply one.
In the mind of the site admin, the site users, and most other people, this default image is part of branding. If 6 months later the site wants to change its whole look, this image needs to change.
Currently, the only way to do that would be to hack in the DB or overwrite the file with FTP.
(Apologies if this is a duplicate -- http://drupal.org/node/366377 looks related but I don't understand what the outcome or current status of it is.)
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | edit-field.JPG | 49.64 KB | figover |
Comments
Comment #1
greg.harveyAfter IRC discussion, and based on our limited understanding of what KarenS was saying in the post joachim links to, this looks like a potentially nasty bug - it removes functionality that exists in D6 and is really important. We prepared to stand corrected, but unless we're wildly wrong I +1 this bug... =(
Comment #2
niklp commented#drupaluk reprazenttt
+1 - changing defaults is something I do *all* the time.
Comment #3
yched commentedThis is not possible in CCK / Fields D7 model. A default value is just a value that gets proposed to the user in the 'object create' form (or gets saved when incoming field is not specified in the case of programmatic object creation).
Once the object is created, the value is a 'regular' value, there's no way to keep track that it was saved as a 'default value' instead of an explicit user choice.
This is a won't fix. The case of "change branding of the 'no picture' user avatar" will need to be adressed differently (change the actual image file behind the stored fid - imagefield / filefield just store an fid...). I think imagefield / filefield have their own handling of default values anyway.
Comment #4
niklp commentedYou've got to be kidding.
So default values in imagefields, default text in textareas, this *essential* stuff is all gone? Why?
What about the dozens of use cases where I want to set defaults with tokens and then not show the user the form??
Comment #5
damienmckennaSimple scenarios:
This needs to be fixed.
Comment #6
yched commentedre NikLP #4 : "this *essential* stuff is all gone? Why?"
Er, gone compared to what ? This is how 'default values' have always worked in CCK contrib from D5 (when we added the feature), nothing new here. We won't be automatically mass updating your existing data, never have, never will. This is just not the definition of the 'default value' feature.
What was previously possible that isn't possible anymore ?
Now, as I said above, fielfield has always had its own way of handling default value, so I'm not sure if and how the original use case described here (change 'no avatar' image) is actually problematic here.
Comment #7
yched commentedre DamienMcKenna #5:
Your scenarios are far too vague. Unless you provide an actual, detailed scenario of something that was previously possible and is not anymore, there's nothing that "needs to be fixed".
Comment #8
joachim commentedI guess there are two possible ways of implementing the concept of 'default value':
a. value to suggest to the user in the empty form, or saved if no value is supplied
b. value to display when there is no value stored
What this issue is about is b.
The two are not mutually exclusive... providing the UI clearly explains this.
Comment #9
joachim commentedOops.
Comment #10
yched commentedre #8: Spot on.
CCK / Field API 'default value' is and has always been a).
b) is something else, more pertaining to the 'display' side. Can very well be done by formatters, or from a contrib module. Not in core.
Back to won't fix.
Comment #11
joachim commentedSo to be clear, let's call type a. an "autofill" value, and type b. a "display default".
I don't see any technical reason why an autofill can't be changed later in the lifetime of the data. Of course, you can't go back and change the already created data, since the data can't know it how that value got to be set.
The only reason I do see is that users won't understand that they can only change future autofills and not past ones. This can be addressed with good UI and documentation.
As for display default -- isn't filefield in core now?
Comment #12
joachim commentedThis actually appears to have been implemented now :)
Argh, I mean type (a) is implemented. Not looked at b yet.
Comment #13
alexanderpas commentedisn't this very easy, if we're not duplicating the default value across each instance where the default value get's used, and instead store
NULLin the instance to indicate the default value needs to be used instead.an actual empty field (for example, with an optional field) will be stored as
''I suspect to see a checkbox toghether with an imagefield that says "use default image."
the behavior is that when the checkbox is checked it stores NULL and when it's unchecked it stores the content of the imagefield.
while displaying, if it sees null, it checks for the default value and uses that instead.
Comment #14
joachim commentedHmm yeah, this is broken at the moment: the UI lets me change the value, but I get this when I try to save the field settings:
FieldUpdateForbiddenException: field_sql_storage cannot change the schema for an existing field with data. in field_sql_storage_field_update_forbid() (line 226 of /Users/joachim/Sites/7-drupal/modules/field/modules/field_sql_storage/field_sql_storage.module).
Comment #15
1kenthomas commentedIt seems to me there is a potential option, c, such that:
c) the global option to be displayed if the "default option" is shown, for instance, the "default user picture."
This is not necessarily a comment on any of the debates above.
Comment #16
figover commentedHi , i just created a text field in article bundle . Then i created a node of Article Content Type. After creating the node, when i go to edit the field, i am watching an error screen.If a user can not edit field after creating node of that specific content type, then edit link should not work, or something else. I think, this error should not come.
Comment #17
sunhm, now that I actually read this issue... yeah, that's a WTF -- somehow, I'd assume certain fields to not store a value if the value happens to be the field's default value, but instead load/apply that default value dynamically.
A nice example is an image field... a "default image" should not really end up in the DB. You'd "naturally" assume that the default image is only applied when the user did not save something.
Comment #18
yched commentedAgain, default values always worked liked that since they were introduced in CCK 3 years (?) ago - and we're not changing that now (if ever...). A "default value" is just a suggestion used to prepopulate the entity creation form. That's all. Once the form is submitted, the submitted values are regular field values.
If you want a specific display for NULL values, do that in the formatter.
I cannot reproduce the bug mentioned in #16. Thus, setting as 'by design'
Comment #19
joachim commented> A "default value" is just a suggestion used to prepopulate the entity creation form.
In that case, the admin user should be allowed to change the suggestion as long as it's clear that it's not a retroactive change.
Comment #20
yched commented@joachim : that's the case for regular field types, the default value is an instance-level property, and can be changed any time.
Image field choses to opt out of Field API's default handling of "default values", and provide it's own - 'default image' is a field-level setting. I'm sure there's a good reason for this, but if the default image cannot be changed once there are actual data, then it's an issue for image field.
Comment #21
davidzz commentedIf this is an issue for image field, which provides its own 'default image' code, any hope that we can change this? This would be different from changing a CCK tradition, and adds a lot of convenience.
Comment #22
aaron commented@davidzz: sounds like a feature request.
Comment #23
joachim commented> Image field choses to opt out of Field API's default handling of "default values", and provide it's own
To me that sounds like a module not following the conventions laid down by the framework -- hence a bug.
(And users are also going to find this a total WTF.)
Comment #24
moshe weitzman commentedI just checked with the Image field on the article content type in D7. Changes to default image do affect existing nodes. AFAICT, this is Fixed. Please reopen if I have it wrong.