I have a content type with a text list field with checkboxes / radios widget in it.
CSV import seems to work well: I set the value of the field in CSV and after import I can see the value at the node page. However if I edit an imported node of that type, I see that none of the checkboxes selected.
Possible related issue(?): #1080312: Feeds mapping does not recognize text fields using list widget
I still have not try it with the latest dev version, but I'll give it a try and report my experiences.
Comment | File | Size | Author |
---|---|---|---|
#8 | feeds-map-to-allowed-value-1428096-8.patch | 4.27 KB | m.stenta |
|
Comments
Comment #1
thamasTested it with the latest dev version (2012-Feb-09) but had no success.
Comment #2
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedTested and it appears to still be an issue. When you import into a list text field using the label of the field, that data gets imported, but on the edit form there is no item selected.
With the patch from #2379631: field_attach_validate() must be called before programmatic entity saves the item in question isn't imported, but fails on the error "List Text: illegal value."
Currently, Feeds only supports importing into list text fields using the keys of the field.
For example, given the following allowed values:
Feeds only imports correctly when the source is "a", "b" or "c" (keys used in the list field), but not when the source is "Item A", "Item B" or "Item C" (labels used in the list field).
Comment #3
le72So what to do if source CSV contain "Item A", "Item B" or "Item C"?
Comment #4
MegaChriz CreditAttribution: MegaChriz at WebCoo commented@le72
Changes should be made in feeds/mappers/list.inc, feeds/mappers/number.inc and feeds/mappers/text.inc to add support for importing items by label. To do this, changes should be made each target callback for a list field. These target callbacks are
number_feeds_set_target()
,list_feeds_set_boolean_target()
andtext_feeds_set_target()
. The following changes need to be made in these functions:Comment #5
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedMarked #2879163: Feeds import keys instead of values as a duplicate.
Comment #6
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedComment #7
brockfanning CreditAttribution: brockfanning commentedHere's my attempt to add this feature.
Comment #8
m.stentaThanks @brockfanning for the patch!
In my case, I am providing the list of allowed values for my fields programatically, using the "
allowed_values_function
" field setting. In these cases, the "allowed_values
" setting is empty, so the patch doesn't help. I modified your patch slightly so that it would also work with that setting. I used thelist_allowed_values()
function provided by the List module (which, along with the Options module are what provide the "allowed_values
" setting). This function checks both settings and builds an array accordingly.It's working great for me! I would RTBC this, but because I changed it someone else should review.
Comment #9
m.stentaOne thing I'm noticing however: I am not seeing the error described by @MegaChriz in comment #2 above when I add a non-allowed value in my CSV import file. I am using 7.x-2.0-beta4, so I do have the new validation logic added by #2379631: field_attach_validate() must be called before programmatic entity saves. I will debug a bit to see if I can figure out why.
Comment #10
m.stentaOk, I remember why I'm not seeing the validation error - it's because the field I am importing to is within a Field Collection. I discovered this issue a few months back and commented on it in the Field Collection feature request for Feeds integration: https://www.drupal.org/project/field_collection/issues/1063434
So that's probably an issue in the Field Collection module, not in Feeds. Disregard for now. :-)
Comment #11
MegaChriz CreditAttribution: MegaChriz as a volunteer commented@m.stenta
It would be great if we have an automated test for this feature. Do you want to create one?
Comment #12
vchen CreditAttribution: vchen commentedI tested patch8 and it still doesn't work for me. I used the key, the label, even tried numbers where the first pair = 0, etc.
Nothing imported for that field; it's always blank (no checkboxes were checked).
Comment #13
vchen CreditAttribution: vchen commentedActually, patch 8 works. I accidentally deleted my importer and had to recreate it again. After I rebuilt the importer and ran another import, the list value populated correctly.
Comment #14
danharper CreditAttribution: danharper as a volunteer and at hrpr commentedI'm looking for this in Drupal8, shall I log a separate issue?
Comment #15
NWOM CreditAttribution: NWOM commented#8 works great! I would love to see it get added to the module. Thanks for everyone's work on this!
Comment #16
Frosty29 CreditAttribution: Frosty29 commented#8 was a great help - thank you! There was one issue I had to solve manually.
My list had
1|Most Junior
2|Junior
3|Middle
4|Senior
5|Most senior
Items with "Most senior" would not import. The feeds log shows it as "Most 4" not valid - i.e. the "senior" had been subsituted already, for the key of 4.