Problem/Motivation
Using a views field that is rewritten as a link, and outputting via a Dropbutton field in views, results in the url being altered.
Using a view to get a listing of clients, a custom route and controller is setup to fetch a custom form to edit a client. The controller returns a AjaxResponse to replace the view content with a custom form for the client.
When using views, a field for the node id was added. This field was then rewritten into a link, and output in the view. The url being created points to to the route mentioned above. When the view is output, and the id field is output as a link, the output is exactly what is expected. However, when the url output is different when routed into a Dropbutton element.
Steps to reproduce
- Create a new environment on Simplytest.me that is just Drupal core
- Create 3 basic page nodes
- One will suffice, but 3+ is ideal.
- Just need the title and the nid
- Add a view
- Output in table display.
- Add fields to view:
- Content: Title (default)
- Content: Nid (expecting a field machine_name of
nid
; substitute as appropriate.)
- Under "Rewrite results", check
Output this field as a custom link
- For "Link path", set
/ajax/edit-client/{{ nid__value }}
- For "Link class", set
use-ajax
- Check
Strip HTML tags
- Check
Remove whitespace
- Edit link
- View link
At this point, the view should display a table. The column outputting the node id as a link, is properly linking to /ajax/edit-client/1
, or the respective nid.
- Edit the view
- Add a new field for "Global: Dropbutton"
- Include the field for id that was rewritten into a link
- Include the view link
- Include the edit link
At this point, the id field still outputs the correct link, and the link should also be included in the dropbutton field. However, the link outputting in the dropbutton does not match the link output as a field.
[EDIT] Additonal context
The use of ajax
in the url was thought to be suspect. The issue still happens with a custom url like /custom/edit-client/1
.
Expected results
The column output for the rewritten id field includes a link, with the id as the link text.
The dropbutton includes the exact same link that the id column displays.
i.e. <a href="/ajax/edit-client/1" class="use-ajax">1</a>
Actual results
The dropbutton link outputs a different url; with /ajax
, and the numeric node id, removed, and the use-ajax
class is not included.
i.e. <a href="/edit-client/">1</a>