Needs work
Project:
Multifield
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
13 Jul 2013 at 21:40 UTC
Updated:
3 Aug 2018 at 12:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jenlampton+1 yes please :)
Comment #2
sbilde commented+1 Would be really awesome. - Will totally eliminate the need for field collection for me, if this was possible.
Would this also make it possible to aggregate the individual sub-field values?
Comment #3
dave reidI started working on this on the last weekend and tried a couple of 'easy' things to make Views support which didn't pan out. It looks like I need to write my own Views field handler that works similarly to views_handler_field_field. I started work in a branch but it's not at all ready yet even for alpha testing. But just confirming this is on my radar and something I want included in the next release.
Comment #4
sbilde commentedSounds great. - Whenever you have something ready for test, just say the word :)
Comment #5
filijonka commentedperhaps you consider it to early but it would be interesting to see it on the repos. then if other have time they might already now be able to ship in some time on it.
Comment #6
doub1ejack commented+1 & Following. Tested out this module and it works very nicely for my simple, text-field-only, scenario. The only thing holding me back is an inability to access the data in views.
Comment #7
Anonymous (not verified) commentedVery interested in this module as a replacement for Field Collections.
Only feature gating factor I can think of is robust Views support for the sub fields. Being able to access the content from views is critical.
The single instance of each sub field is fairly minor.
Comment #8
Heihachi88 commentedAny updates on this?
Comment #9
FreeXenon commentedYea, I this has been my big bugbear too!
I would just use Field Collections, but there is no View Support.
You have some which is awesome, and I cannot wait until it does.
As trainingcity said above access to field values in views is critical.
Keep up the good work.
Comment #10
attiks commentedFYI: code is at http://drupalcode.org/project/multifield.git/shortlog/refs/heads/views-i...
Comment #11
attiks commentedI thought about this a bit, and it sounds similar to the views integration for addressfield, only differences are that the composition is dynamic and it uses real field formatters, but it might be a good starting point?
Comment #12
attiks commentedAttached patch is against the views-integration branch, it makes the sub field show up so they are selectable, the views options are using the right hanlders, but no data is outputted.
Uploading here so maybe somebody else might find it usefull.
Comment #13
attiks commentedAlternative solution (untested) might be to define a new table definition in views with the subfields and define a new relation between the entity base table and the field_data table
Comment #14
jelle_sPatch based on #12. Field values are now displayed. I'm not exactly sure how robust this approach is. I tested it with taxonomy:
Comment #16
jelle_sAh yes, the patch was made against the views-integration branch, as @attiks did, so it will probably not apply to 7.x-1.x...
Comment #17
jelle_sNew patch with some cleanup & using the handler @Dave Reid had already started writing. (Patch is again against views-integration branch)
Comment #18
attiks commentedWe're getting closer, field is showing data, but if you select to show them on separate rows, it shows all values on all rows
Comment #19
attiks commentedNew patch with support for multiple records
Comment #20
attiks commentedworking patch
PS: rewrite result is not working, and multi lingual is not tested.
Comment #21
jelle_sFixes rewriting results & click sort
Comment #22
jelle_sFixes another issue where rewriting results was working in preview, but not when actually viewing the view.
Comment #23
Kokosnoot commentedSorry, but I do not have the following file in my multifield module: /MultifieldViewsHandler.php. Where can I find this?Sorry for my answer, I have found the git link.
Patch works fine here, subfields can be added in Views now.
Comment #24
drupauler commentedHello Chaps, I'v been having a play. Mega Kudos to all involved.
My use case is to create a multifield for location information which is presented in a views table, and for that the patch seems to works fine.
However, when I build a view to display the geofield locations with format geofield map, I'm stymied because geofield map is looking for a field of type geofield and what it is presented with is a field of type multifield:geofield.
I suspect this an issue for geofield_map rather than multifield but I mention it here as it could be a generic problem.
Thanks again
Comment #25
attiks commented#24:
Yes, known problem (for now), we're facing the same with date fields in combination with full calendar module, would be nice if we could solve this in the multifield moduleUpdate: problem was related to the date module, so your problem is probably something else, you could check the code to see how they decide if a field is appropriate or not. FYI date fields in views are using a key "is date" in the definition.
Comment #26
attiks commentedMarking as RTBC, since marking as NR will trigger the testbot
Comment #32
jelle_sPatch against 7.x-1.x-dev so the testbot is happy again.
Works exactly the same as the patch against the views-integration branch from #22
Comment #33
jelle_sThis patch works better with date and fullcalendar. The field_info property of the MultifieldViewsHandler now contains the field_info of the subfield.
Comment #34
jelle_sImproved patch for rendering the multifield subfield values in views.
Comment #35
aburrows commentedTested patch and it shows missing handler error in views
Comment #36
attiks commentedDid you clear all caches (drush cc all) and the views cache (drush cc views)?
Comment #37
PieterWintmolders commentedSame problem here; Broken/missing handler.
Views 7.x-3.7
Notice: Undefined index: element_type_enable in views_handler_field->options_submit()
Notice: Undefined index: element_label_type_enable in views_handler_field->options_submit()
Notice: Undefined index: element_wrapper_type_enable in views_handler_field->options_submit()
Notice: Undefined index: element_class_enable in views_handler_field->options_submit()
Comment #38
PieterWintmolders commentedFound the issue
Had to add 'files[] = MultifieldViewsHandler.php' to the multifield.info.
Works like a charm now, thanks!
Comment #39
attiks commentedI should be there, how did you apply the patch?
Comment #40
PieterWintmolders commentedI think the problem is that I started with the '7.x-1.0-unstable9'-version.
That multifield.info doesn't contain 'files[] = tests/MultifieldDevelGenerateTestCase.test' and made the patch ignore the info-file?
Comment #41
attiks commented#40: That explains a lot, you always have to start from the dev version if you want to apply a patch
Comment #42
attiks commentedAFAIK this is RTBC
Comment #43
dave reidReviewing today.
Comment #44
Molfar commentedSo, is there any progress with views integration? At project's page a links to this issue marked as green. What does it mean?
Comment #45
dave reidRe-rolled, updated, and fixed variables names. Moved Views hooks to multifield.views.inc. Can someone confirm if this updated patch is still working as before?
Comment #46
mihai_brb commentedThis was exactly what I was looking for!
I don't know how it worked before. I just tested with a multifield of entityreference and some other decimal/text fields and it worked. All sub-fields show up in views.
Thanks,
Mihai
Comment #47
attiks commentedMihai, if it works you can mark it RTBC
Comment #48
attiks commented@jelle_s can you do a quick test?
Comment #49
jelle_sSmall fix and a bit of cleanup.
Comment #50
dave reidComment #51
attiks commentedI guess this needs a reroll based on #2234769: Should multifield types be represented as separate field types, or just one 'Multifield' field type?
Comment #52
dave reidI didn't see anything specifically that needed to be changed in this patch as a result of #2234769: Should multifield types be represented as separate field types, or just one 'Multifield' field type?. That's the beauty of having all the wrapper APIs available.
Comment #53
jelle_s@Dave: I combined the patch from #2234769: Should multifield types be represented as separate field types, or just one 'Multifield' field type? with this one in that issue. Some changes were needed as in the views handler class
$field['type']was called directly in stead ofmultifield_extract_multifield_machine_name. And it needed a reroll anyway since it didn't apply anymore after applying the patch from #2234769.Comment #54
dave reidLet's not combine the patches please and update this one assuming that 2234769 will be committed.
Comment #55
dave reid@Jelle_S: I'm seeing multifield_extract_multifield_machine_name() being used properly multifield_field_views_data and related function in the latest patch here, I'm not sure what you mean.
Comment #56
jelle_s@Dave
This is the one I was talking about.
This one as well.
Comment #57
dave reidYeah, those should definitely be using the API and should be fixed in this issue.
Comment #58
jelle_sNew patch that fixes the issues from #56
Comment #59
jelle_sRerolled patch (patch will fail because current dev without this patch fails as well: https://www.drupal.org/node/1992610/qa)
Comment #60
bigpun6681 commentedHello Jelle_S,
i used your patch and everything works fine. Thanks a lot for that great patch.
If the first value in the column is empty it's not printed. Is it possible to implement an option, to print the first value even it's empty. An answer would help me so much.
Greetings
René
Comment #61
BenVercammen commentedI've applied 2041533-59-views-integration.patch and can now successfully use a contextual filter on multifield subfields in my views. Thanks!
Comment #62
0nly_tom commentedThank you very much for this patch.
Comment #63
imclean commentedTrying this out but running into a situation where
MultifieldViewsHandler::post_executeis firing 14 times.This iterates over the values and executes set_items() each time. Not so bad with a small number but we have one with 185 fields, which leads to 2,590 calls to set_items! Very slow.
I'm not sure why this is happening yet, or if it's something specific to our set up.
Comment #64
imclean commented14 is how many sub fields we have.
So, post_execute is getting called for each sub field, then calling set_items() for all rows each time.
Comment #65
imclean commentedOk, I'm a bit slow here. Clearly each subfield needs to be set for each row.
Comment #66
mkinnan commentedWhen I filter by a multifield subfield of type date, I get the following error:
Notice: Undefined index: tz_handling in date_views_filter_handler_simple->init() (line 21 of /var/www/html/sites/all/modules/date/date_views/includes/date_views_filter_handler_simple.inc).I add the subfield to the filter section. As soon as I do that, I see the error messages in the drupal log. It does not seem to matter what the filter settings are for the date field.
Comment #67
TazimHossain commentedHi,
when i try to display my multifield field in views, after patched #59, views say "Broken/missing handler".
please...
can anyone help me...
waiting for any response.
Thanx.
Comment #68
deanflory commentedMaybe try editing the individual fields in the View and just saving them, sometimes that updates code. Then save the View. Just a thought.
Comment #69
bellagio commentedAfter applying #59 patch, i get Warning: array_walk() expects parameter 1 to be array, boolean given in MultifieldViewsHandler->set_items() (line 849 of ..\multifield\MultifieldViewsHandler.php).
Warning: Invalid argument supplied for foreach() in MultifieldViewsHandler->set_items() (line 851 of ..\multifield\MultifieldViewsHandler.php), only when i added the newly available 'multifield: myfield_name' to the fields.
Comment #70
mustanggb commentedI have a problem with #59 caused by:
It's kicking out the following warnings:
php_pre_execute seems to be something used by views_php
Comment #71
mustanggb commentedComment #72
mustanggb commentedOkay so the "problem" is __call() responds true to is_callable(), I think the best thing to do is to check our method is callable as well.
i.e.
Comment #73
dobe commentedI applied the patch and everything seems good so far. I am also exposing this to services and the services raw output works nicely.
-Jesse
Comment #74
loparr commentedPatch throws
Warning: array_walk() expects parameter 1 to be array, boolean given in MultifieldViewsHandler->set_items() (line 849 of /sites/all/modules/multifield/MultifieldViewsHandler.php).
Warning: Invalid argument supplied for foreach() in MultifieldViewsHandler->set_items() (line 851 of /web/sites/all/modules/multifield/MultifieldViewsHandler.php).
Hovewer, the error is not shown if I display results inside view (using argument)
Comment #75
epringi commented#59 works like a charm, thanks guys! :)
Comment #76
mustanggb commentedFound another issue, filtering by a multifield subfield that is a list complains that is can't find it's allowed_values.
Comment #77
Bensbury commentedI applied the patch from #59 and seems to have worked fine for subfields that are text format and term reference.
Only minor thing is they are not sortable to a Table Display, but can use javascript for that.
Comment #78
mustanggb commentedFollowing on from #76, if we want to use the original filter handler for subfields rather than our write own then in the case of lists at least the field_name must be correct so it can load the allowed_values, the following changes to the patch in #59 solved it for me:
multifield.views.inc
Comment #79
osopolarThe warnings in #69 and #70 will appear, when a multifield is empty. See
field_get_items, which returns false if$entity->{$field_name}[$langcode]is not set.I changed the patch from #59 to check if the $multifield_items variable is an array. If not I set it to an empty array.
Interdiff:
About the error in #70: I can't reproduce that. But maybe it's because I don't use multifield-fields as filter or sort criteria. I also can't see who is trying to call
php_pre_execute, maybe it's a error of that module calling non existing/registered functions?I am not familiar with
__callfunction. I haven't seen the proposed checkis_callableanywhere else in __call methods. But I found a post from Larry Garfield (Crell) from about 8 years ago, called Magical PHP: __call(), where the dynamic methods have to be registered before they could be used. Maybe this should be used here too?Comment #80
osopolarComment #81
akumajo commented#79 works fine with dozen of subfields...
any ETA for a new release ? would love to use this KICKASS module for new projects
Comment #82
bkat commentedThis patch is working pretty well. However, I'm trying to use editablefields with subfields contained in multifield. I have editablefields working on node edit with a change I submitted. https://www.drupal.org/node/2643362
However with editablefields its not working correctly. I'm not entirely sure if editablefields or this patch is making poor assumptions.
It looks like we need the entity to be the editablefields pseudo entity. However, when rendering an editablefields in a view, editablefields_field_formatter_view calls
This is called when MultifieldViewsHandler calls
$render_array = field_view_field('multifield', $multifield, $this->definition['subfield_name'], $display, $subfield_langcode);Which replaces the $entity passed in with the parent node (in all my cases) but the entity_type remains 'multifield'.
For now, I just wrapped the editablefields code in a check for multifield
But that's not a real solution. I can raise an issue with editable fields as well.
Comment #83
edysmpApply change from #78, it this work for filter criteria.
Comment #84
attiks commentedComment #85
kansaj commentedProbably it should be
Comment #86
paulwdru commentedHi,
I'm totally lost, which patch shall apply to which version ?
Thanks
Comment #87
paulwdru commentedHi,
I apply patch #83 to 7.x-1.x-dev successfully, it resolves Select Text List field in exposed filter with options display, however Entity Reference field (referencing taxonomy) is still unable to be used as Filter Criteria.
I did try adding whatsoever relationships following the normal practice with Entity Reference but it still does not show up in Filter Criteria.
Any idea ? Thanks
Comment #88
vblanco7 commentedI apply patch #83 it's work!!
thanks!!
Comment #89
attiks commentedSo back to needs work, or we handle Entity reference in a follow up
Comment #90
mustanggb commentedBased on this issue's popularity and that it's a release blocker hopefully no-one minds bumping the priority up a little.
Comment #91
glynster commented@MustangGB RTBC +1 Please commit!
Comment #92
mustanggb commentedStraight re-roll of #83, NR for tests.
Comment #93
mustanggb commentedWhoops, wrong textarea, didn't mean to edit IS.
Comment #96
mustanggb commentedHmm fussy, trying again.
Comment #100
mustanggb commentedStrange, tests are passing fine for me locally.
Comment #102
dave reidTest failure is a recent change in Drupal 7 that added the 'administer fields' permission. I fixed this with #2737837: Update tests for new 'administer fields' permission.
Comment #103
lingaraj_m commented#96 Works like a charm now, thank you.
Comment #104
darol100 commentedI can confirm that the patch from #96 works fine.
Comment #105
glynster commentedRTBC +1 Please commit for the next release!
Comment #106
glynster commentedLooks like this did not make it into the Alpha 4 release :(
Comment #107
glynster commentedPatch #96 still works well against Alpha 4 release! RTBC +1
Comment #108
anybody+1 for a commit soon!! :)
Comment #109
crawcole commentedWorking well except for filtering by Entity Reference, which is a major downside.
Comment #110
mustanggb commentedI re-found the view that was causing the problems for me in #70.
Can handle it here or as a follow-up, I'm not really fussed.
Comment #111
alabandit commented#96 worked for be on PHP 7
Weirdly had to install uninstall a module to trigger it (Normal cache clear didn't work).
Comment #112
W.M. commented#96 works fine under PHP 7, thank you very much @MustangGB.
Kindly consider committing patch to stable release.
Comment #113
kris77 commentedHow can i add a Relationship in VIEWS?
I trie to use it with VBO module to delete a multifield item.
Thanks.
Comment #114
mvdve commented@Kris77. Please open en new issue when you have a question not related to this one.
Comment #115
kris77 commented@mvdve I'm sorry. I thought it could be integrated in this patch.
I have create a new issue here
Thanks
Comment #116
mustanggb commentedIn PHP 7 #96 generates the following notices.
Notice: Undefined offset: 0 in MultifieldViewsHandler->set_items() (line 868 of multifield/MultifieldViewsHandler.php).The simple solution would appear to be this, if anyone cares to re-roll.
Comment #117
rudi teschner commentedI think this patch needs some more work.
It seems some of the logic applies even though the view has no multifield items at all. For example the post_execute hook in MultifieldViewsHandler.php gets executed in my search_api view while the multifield field added to one of the content types is not even indexed.
Which causes my search_api view to run into a 120 second timeout.
Comment #118
rudi teschner commentedAdditionally it seems that adding an relationship to a view based on an entity_reference field inside a multifield causes 'SQLSTATE[42S22]: Column not found: 1054 Unknown column' in 'on clause'.
Comment #119
rudi teschner commentedFor the start I've focussed on the relationship-problem, but I cant seem to get closer to fixing it than this:
1) Multifield table name: field_data_field_multifieldname
2) Subfield columnd name field_multifieldname_field_subfieldname
3) views_query() puts together query and uses 'real field' value field_subfieldname as column against table field_data_field_multifieldname
4) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_multifieldname.field_subfieldname' in 'on clause'
If i hack the function query() in views_handler_relationship.inc of the views module and change the 'real field' values right before the query is executed by adding the missing präfix, the relationship and the view are working.
Sadly, I'm not too familiar with views or multifield to have any idea on how or where that can be changed, nothing I've tried managed to get through to the query.
Comment #120
csc4 commentedTried the patch at #96 and can see fields but am getting composite results not individual lines (ie result for entire multifield not results for the subfields) is that the intent or have I missed something?
Also can't see any way to sort on multifield subfields?