Needs review
Project:
Data
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Aug 2018 at 18:47 UTC
Updated:
15 Jun 2020 at 16:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
roderikThe amount of feedback I have on this, surprised me. And it's partly subjective.
1)
I'd rather have this extend views_handler_field_node_link than (its child) views_handler_field_node_link_edit, because
It's a bit unfortunate that views_handler_field_node_link does all kinds of other things on init() and pre_render() - it loads the entities into the handler, which we don't use. But hey, all the other fields in the table load the same entities so it doesn't really matter that much. I just added some comments on why we are extending views_handler_field_node_link.
2)
You're not only adding a text element for the text; you're also doing token replacements on that text - but the element's help text does not say that. That made me curious and I had a look at what other handlers are doing. As it turns out, there are 3 ways of displaying custom text with possible token replacements:
a. What you are doing: add a "Text to display" element and then calling tokenize_value() on its contents. In that case it would be nice to have the text element specify the possibility of token usage.
b. Do not call tokenize_value(); only use the literal text that the views handler provides. This text can still (already) have token replacements... but for that, the user needs to use the "Rewrite results" options in the form. Just like with many other fields.
c. Do not add the "Text to display" element at all! Because the "Rewrite results" option is available for displaying custom text - with or without replacements.
For option c, We can just keep extending views_handler_field and fix just the one line:
The standard handlers for node/user/term links all do option b. Apparently option c is too difficult to find for users?
I'd personally rather do option b than a - just to be consistent with Views standard handlers (and to call as few icky functions as possible. Then I don't need to think about what could theoretically happen if you re-tokenize an already tokenized text from the "Rewrite results" section. Though it's very likely harmless.)
So, my patch added as a somewhat subjective alternative.
Comment #3
roderikFYI - My review here has led to creating a new base field handler for the edit link (and the delete link). This includes the translation.
It's in #2744843: Remove Entity ID field requirement - but that moves the edit link to data_ui at the same time.