Problem/Motivation
Revert of #3206625: ID attribute is missing from blocks rendered by BlockFieldFormatter.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | revert-block-id-3223741-2.patch | 1.66 KB | berdir |
Issue fork block_field-3223741
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
Comment #2
berdirJust a direct revert patch for now, I'm open to patches that add a HTML attribute as discussed in that other issue or through a #block_field_id or whatever.
Comment #3
anybodyI agree this makes sense, at least it should not simply use
->getMachineNameSuggestion()but maybe add ablock_fieldprefix or suffix or something like that. Of course that's also no *real* solution, but better than predicting it's something it isn't and risking duplications.How to proceed here?
Background: We wanted to determine the region the *real* block (not the block field) is in (by checking #id). But without this patch they all have the same
#idso this isn't possible. Maybe @Berdir had similar issues in his projects?So +1 on reverting that change (and looking at the suggestion above to have *an* #id (but not the same).
PS: Maybe it would be good in general to indicate that this is a block rendered by block_field? (which would also happen by the prefix / suffix, so I like the idea so far...)
PPS: I implemented that as POC for discussion in the MR.
Comment #5
anybody@Berdir: Any feedback eventually (if you should have the time)?
Comment #6
berdirA prefix isn't going to help. There's still going to be code that assumes #id is a block config entity and will try to load that.
My suggestion in #2 is a separate property like #block_field_id, then you can find it if you're looking for it, although I personally don't think that is very useful because the machine name *suggestion* is a transliterated and adjusted version of the admin label and nothing that you should rely on in code.
region is a block config entity concept, it does not exist for block_field blocks. but you could say that all block_field blocks are in a in-content pseudo region, then some kind of flag could be useful.
I'm unsure about committing this because it's been 3 years now and even though the project isn't stable, it's still a change.
Comment #8
anybodyThanks @Berdir I added #25 - don't have the time now to look into it deeper, especially what to use for the id attribute, but this should be a first step.
Regarding
That's right, but in that case we needed a way to determine the right one and that was the only specific option here. Good enough for that project in other words. No general solution of course.
How should we proceed?