The poll form/results always appears above other fields regardless of the order specified in "Manage display"using drag & drop.

I was able to resolve this issue by changing the key name for the "Vote form/Results" field specified in poll_entity_extra_field_info() from ['poll_votes'] to ['poll'].

After making this change, flushing cache and reloading the Manage display page I am able to drag & drop fields to the desired order, save and the fields are displayed in the order expected.

I don't know if there is a better way to resolve this issue. However, I have not noticed any adverse side effects with this approach.

Issue fork poll-3082110

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rjkuyvenhoven created an issue. See original summary.

berdir’s picture

Version: 8.x-1.2 » 8.x-1.x-dev
Status: Active » Needs review
Issue tags: +Needs tests

If that works then that probably makes sense, nice catch. Since we got this wrong, it would be very useful to have test coverage for it though.

rjkuyvenhoven’s picture

I can see if I can find some time to do add test coverage. However, I don't have experience writing tests for Drupal and it's not clear to me how one would go about testing this particular issue.

berdir’s picture

Status: Needs review » Needs work

Yeah, it isn't trivial.

We have \Drupal\poll\Tests\PollFieldTest::testPollFields() which tests that fields can be added and are displayed on edit & view.

So what we should do is set some weights there on the view display page, save that and then check the order of elemnts on the page.

Typically, that's done by getting the strpos() of the given strings in the page content, make sure they are not empty and are in the expected order.

ceseia’s picture

rjkuyvenhoven solution helps me as well

kunalgautam’s picture

Status: Needs work » Needs review
StatusFileSize
new2.44 KB

Patch with fix phpunit as well

Status: Needs review » Needs work

The last submitted patch, 6: poll-manage-display-fix-3082110-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

kunalgautam’s picture

StatusFileSize
new2.43 KB

jidrone made their first commit to this issue’s fork.

jidrone’s picture

After deeper testing I think the issue is related to how the entity theming is being managed.

There are other issues related like #3202785: Manage form display issue and #2936955: The order of output of fields before voting, I also had an issue using field group module.

I will start a merge request with an approach than can fix all of them.

ivnish’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Assigned: Unassigned » ivnish
Issue tags: -Needs tests
ivnish’s picture

StatusFileSize
new5.2 KB

I rerolled MR to the latest dev of 2.0.x branch and added functional test of field weights

ivnish’s picture

Status: Needs work » Needs review

@bramdriesen can you review it?

bramdriesen’s picture

Assigned: ivnish » bramdriesen
Issue tags: +MountainCamp2024

Will convert the patch into an MR to see what the test results say.

bramdriesen’s picture

Status: Needs review » Reviewed & tested by the community

To me this is RTBC. Will check with @Berdir if this is ready to commit.

ivnish’s picture

Super! Can you contact with @Berdir?

berdir’s picture

Seems like a sensible thing to do, especially in a new major branch.

> Super! Can you contact with @Berdir?

Berdir is always listening ;)

  • BramDriesen committed 23f98258 on 2.0.x
    Issue #3082110 by jidrone, kkalashnikov, BramDriesen, ivnish,...
bramdriesen’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 2.0.x, thanks all!

bramdriesen’s picture

Assigned: bramdriesen » Unassigned

Status: Fixed » Closed (fixed)

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