Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you have cck fields in node's created by feeds it wont pick up he default value for that field.
At first i was thought it was only the pollfield cck field: http://drupal.org/node/674004
But after seeing the same issue with other modules i tested it with a plain text cck field. It has the same behavior. Not picking up the default value you set for it ending up with an empty field with node's created by feeds.
Best regards,
Sergio
Comment | File | Size | Author |
---|---|---|---|
#9 | 705588_map_cck_field_default_value.patch | 1.73 KB | voxpelli |
Comments
Comment #1
alex_b CreditAttribution: alex_b commentedCould you find out where exactly CCK populates default values?
Comment #2
sergio_ CreditAttribution: sergio_ commentedits stored in the database in the table "content_node_field_instance" wich contains fieldname records like "field_test" for example. Then in that fieldname record there is an item "widget_settings" wich contains the settings in this style:
a:4:{s:4:"rows";i:5;s:4:"size";s:2:"60";s:13:"default_value";a:1:{i:0;a:2:{s:5:"value";s:7:"test123";s:14:"_error_element";s:42:"default_value_widget][field_test][0][value";}}s:17:"default_value_php";N;}
In this case "test123" is the default value. I don't know if cck has some api/commands to retrieve it code wise.
After you created a node cck usualy saves the data in the table "content_type_movie" (movie being the content type its used in) that contains a vid(?) primary, a nid(node id to link) and the cck fields used in the content type in his case "field_test_value"
Comment #3
alex_b CreditAttribution: alex_b commentedSorry - wasn't clear enough. I meant where it populates the values, not stores them. So on which callback / hook does CCK populate default values on a node? I assume it happens somewhere beneath node_object_prepare() - correct? If so, default values should be present before mapping, but mapping overrides the default values. If not, I'd be curious as to where else default values are being populated.
Comment #4
drewish CreditAttribution: drewish commentedI wonder if the default was added after the nodes were created. My recollection is in that case the default isn't stored until the node is edited and saved again.
Comment #5
jay-dee-ess CreditAttribution: jay-dee-ess commentedDoes the patch here:
http://drupal.org/node/612060
Help with this issue?
Comment #6
alex_b CreditAttribution: alex_b commentedRelated report: #857216: Behavior on importing empty/NULL/invalid dates
Comment #7
herd45 CreditAttribution: herd45 commentedHas anyone found a workaround for this? I would like to create a content type that includes some fields that are imported by Feeds, and other fields that use CCK default values. My default values work fine for nodes that I create manually, however the default values do not appear for nodes that are created by Feeds.
Comment #8
Hanno CreditAttribution: Hanno commented@herd45: this is another scenario than I thought of.
I become aware that there are two cases for default values:
1. mapped cck fields with empty source values should be set to a default value
2. not mapped fields, should also get a default value, your case.
Case 2 is only needed on feed item creation and not on feed item updates. Case 1 however need some special attention for feed item updates: if a feed item is updated and the source value becomes empty, the behavior should be that the target value should fall back to the default value.
To make case 2 happen, we should build a node with all the default values filled.
I think this is working in the node_import.module in node_import.inc. I am not sure about this, but I think there is at the moment a difference between the feeds module and the node_import module in the way nodes are created: feeds doesn't build a node form, but just saves a node, whereas node_import and first build a node form, with default values and with all modules able to hook (like the module automatic nodetitle) and then submit and validates the node.
Is this indeed the case, and if so, is this by design?
Comment #9
voxpelli CreditAttribution: voxpelli commentedI'm attaching a patch which uses default values for all empty values. It should perhaps be optional.
CCK adds the default values to the form and not in a nodeapi_prepare function which is a bit odd. To solve all problems the CCK values should be added in a nodeapi_prepare function - something that CCK itself needs to do, but also such a major change that they probably can't change it in 2.x.
To solve all cases of default values a patch against FeedsNodeProcessor.inc would be needed that exposes a way to add default values that isn't added in a nodeapi_prepare function.
Comment #10
Hanno CreditAttribution: Hanno commentedvoxpelli: great work.
This patch is a solution for mapped fields (case 1 in #8).
With the proposed patch I see probaly a conflict with #873198: Import multiple values to tag vocabulary. When we have multiple source fields and the first one is empty, I am afraid that the target field becomes incorrectly filled with the default value. What dou you think?
Comment #11
voxpelli CreditAttribution: voxpelli commented@Hanno: Might be that no default at all is inserted - have to check that out. But we shouldn't be rolling patches that are dependent on each other - right? So lets wait until one of them has been committed and then adjust the other one to accommodate those changes?
Comment #12
AntiNSA CreditAttribution: AntiNSA commentedI am having the exact problem as the first post in this thread... I see there is some sort of conflict going on between this and another patch? What am I supposed to do? I cant get inherit taxonomy to work to I am trying to set a default cck taxonomy value...
Comment #13
AntiNSA CreditAttribution: AntiNSA commentedok I am really stupid. I assumed taxonomy would automatically be inheritted, and not that you have to set the mappings. Works great. Thanks. defualt values of cck fields are not inherited when left empty though.
Comment #14
Hanno CreditAttribution: Hanno commented@voxpelli #873198: Import multiple values to tag vocabulary is now committed , so now we can test what will happen with multiple source fields and your patch #9
Comment #15
alex_b CreditAttribution: alex_b commented#10 is a good point. When andrewlevine and I were working on resetting mapping targets before mapping to them we were talking about a reset callback.
Could be:
that reset callback could be where mappers/content.inc populates defaults. It's kind of a second pass node_object_prepare() :P
Comment #16
minghui.yu CreditAttribution: minghui.yu commentedI applied patch in #9 and it does not seem to work.
I am using beta9.
After importing RSS feed, value for a content type (text area) is still empty, though I have specified default value for that field.
Comment #17
minghui.yu CreditAttribution: minghui.yu commentedAny time-line on when this will be fixed? (Case 2 in #8)
Thanks,
Comment #18
Vote_Sizing_Steve CreditAttribution: Vote_Sizing_Steve commentedI think this also effects computed fields not being generating.
Comment #19
manuj_78 CreditAttribution: manuj_78 commentedsubscribing
Comment #20
minghui.yu CreditAttribution: minghui.yu commentedNew release (beta 10) does not cover this issue yet.
Any timeline for this issue?
Thanks,
Comment #21
voxpelli CreditAttribution: voxpelli commentedIf someone updates the patch to address the issues mentioned here then I'm sure it will get accepted. I unfortunately haven't had the time yet as I'm managing very many projects at once right now. As in many opensource projects I think there's no timeline for this - it happens when someone decides to do something about it - feel free to do so :)
Comment #22
sillygwailoComment #23
sillygwailoStill true in Beta 10.
(I don't know what possessed me, in the previous comment, to change the version that this affects to a previous version. I really did mean to change it to the latest.)
Comment #24
hampshire CreditAttribution: hampshire commentedsubscribing
Comment #25
uwe_a CreditAttribution: uwe_a commentedsubscribing
Comment #26
lolmaus CreditAttribution: lolmaus commentedSubscribing
Comment #27
Bartezz CreditAttribution: Bartezz commentedsubscribing, not picking up default version on cck link fields either...
Comment #28
TommyK CreditAttribution: TommyK commentedSubscribing. Also, I'm happy to test any patches that get made.
Comment #29
twistor CreditAttribution: twistor as a volunteer commented