I have two content types: Parent & Child and my ultimately goal is to have an admin tab pointing at a view that emulates the core drupal book module's ordering behavior at a better URL such as /node/%/order-pages. One parent may have many children, but children may have only one parent, defined by an entity relationship with a field on the child pointing to the parent. Weights are set on the children.
When I build a view (or slightly modify the included "weight" view) of "all" child objects in the site to construct a draggable admin table, adding required fields and weight, everything is fine. Similarly, if I add a Contextual Filter to filter to a specific NID, everything works fine and I only see a row for that one object and it's weight. But if/when I try to limit the view by adding a relationship, so that my contextual filter points to the parent's NID, and the table displays the limited set of referenced objects, the weighting feature no longer works. In the views admin screen, if/when I toggle the show/hide row weights the select boxes are completely empty whereas without the relationship or contextual filter they would have select boxes with the correct weight values. The display ordering is correct, however. If I go ahead and save and view a page of the view, I get the following errors:
Notice: Undefined property: stdClass::$nid in weight_handler_field_weight->views_form() (line 33 of /path/to/modules/weight/views/weight_handler_field_weight.inc).
Warning: array_key_exists(): The first argument should be either a string or an integer in weight_handler_field_weight->views_form() (line 38 of /path/to/modules/weight/views/weight_handler_field_weight.inc).
Notice: Undefined property: stdClass::$nid in weight_handler_field_weight->views_form() (line 45 of /path/to/modules/weight/views/weight_handler_field_weight.inc).
Warning: array_key_exists(): The first argument should be either a string or an integer in weight_handler_field_weight->views_form() (line 46 of /path/to/modules/weight/views/weight_handler_field_weight.inc).
Notice: Undefined property: stdClass::$nid in weight_handler_field_weight->views_form() (line 53 of /path/to/modules/weight/views/weight_handler_field_weight.inc).
Comment | File | Size | Author |
---|---|---|---|
#6 | weight-7.x-3.x-fix_broken_form_submit_with_relationship-2096231-6.patch | 854 bytes | Ludo.R |
#5 | weight-7.x-fix_broken_form_submit_with_relationship-2096231-3.patch | 656 bytes | Ludo.R |
Comments
Comment #1
tboornaz CreditAttribution: tboornaz commentedFollowing... I am having the same issue.
Comment #2
davisbenThis seems to be working for me. Could you attach an export of your view?
Comment #3
davisbenComment #4
devad CreditAttribution: devad commentedI had the same issue when I have used relationship:
Entity Reference: Referencing entity - A bridge to the Content entity that is referencing Content via field_target
(With that relationship on weight field)
Then I changed my view up-side-down to use:
Entity Reference: Referenced Entity - A bridge to the Content entity that is referenced via field_target
(Without relationship on weight field)
And everything is fine.
Comment #5
Ludo.RI have the same issue where the form submit doesn't work when using relationship.
The entity_key should use the field alias instead of the raw key name.
Here's a patch that solves this issue.
Comment #6
Ludo.RIn some cases, there isn't a field alias, this patch will fix this use case.
Comment #7
VladimirAusApproved and refactored. 🥃
Comment #9
VladimirAusCommitted! 🍻
Comment #10
VladimirAus