Problem with action path for embedded forms

Created on 1 January 2017, almost 8 years ago
Updated 13 May 2024, 7 months ago

Problem/Motivation

Have a problem with an embedded form in a view that EVA adds to an entity.

Steps to reproduce

Here is the scenario:

  • There is one view called drd_domain
  • This view contains two displays: a page (page_1) and a EVA (entity_view_1)
  • The $form['#action'] should go to two different URLs for each of the displays but it always goes to the page

I have found where this is going wrong: \Drupal\views\Form\ViewsForm::buildForm() in line 160

$form['#action'] = $view->hasUrl() ? $view->getUrl()->setOptions($options)->toString() : Url::fromRoute('<current>')->setOptions($options)->toString();

Even if Drupal renders the EVA display, it returns TRUE for hasUrl() and therefore takes getUrl() from the view and will use the URL from the page, for whatever reason. If EVA were on its own in a view, this line above would use fromRoute('<current>') which would give us exactly what we're looking for.

If you want to reproduce this, you could simply install DRD and go to a Core view, which would show exactly the described effect.

Proposed resolution

I don't know how to resolve this but I hope that this analysis is helping you to find the best way out of that. I would hate to have two separate views as this would cause a real maintenance nightmare.

Remaining tasks

  • Add tests
  • Reproduce with core?

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Views 

Last updated about 8 hours ago

Created by

🇩🇪Germany jurgenhaas Gottmadingen

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024