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).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tboornaz’s picture

Following... I am having the same issue.

davisben’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

This seems to be working for me. Could you attach an export of your view?

davisben’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
devad’s picture

I 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.

Ludo.R’s picture

Status: Closed (cannot reproduce) » Needs review
FileSize
656 bytes

I 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.

Ludo.R’s picture

In some cases, there isn't a field alias, this patch will fix this use case.

VladimirAus’s picture

Version: 7.x-2.3 » 7.x-3.x-dev
Status: Needs review » Reviewed & tested by the community

Approved and refactored. 🥃

  • VladimirAus committed 7ae3bacb on 7.x-3.x authored by Ludo.R
    Issue #2096231 by Ludo.R, williamhicks, VladimirAus: Unable to create...
VladimirAus’s picture

Status: Reviewed & tested by the community » Fixed

Committed! 🍻

VladimirAus’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.