In both editor_image_upload_settings_form() and Drupal\image\Plugin\Field\FieldType\ImageItem the field_prefix is set to a div with container-inline. This creates invalid markup similar to
<div id="edit-settings-max-resolution">
<span class="field-prefix">
<div class="container-inline">
<div class="form-item-x">...</div>
<div class="form-item-y">...</div>
<span class="field-suffix"></div>
</div>
</span>
</div>
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2667340-4.patch | 4.12 KB | twistor |
| #5 | 2667340-5-ss-before.png | 560.39 KB | leolandotan |
| #5 | 2667340-5-ss-after.png | 593.11 KB | leolandotan |
| #11 | fix-markup-generated-by-imageitem-2667340-11.patch | 4.38 KB | leolandotan |
| #11 | 2667340-11-ss-re-roll.png | 580.07 KB | leolandotan |
Comments
Comment #2
twistor commentedHere's the simple workaround.
Comment #4
twistor commentedLast patch was an interdiff.
Comment #5
leolandotan commentedHi,
I can confirm that the usage of the #field_prefix and #field_suffix in the max_resolution or the min_resolution item type key causes an invalid markup but with a little different output. Here is the structure I encountered:
To view/reproduce this issue:
Here is the screenshot before the patch was applied:

Here is the screenshot after the patch was applied:

Hope everything is in order.
Thanks!
Comment #6
twistor commentedUpdated IS with better markup description.
Comment #9
daffie commentedComment #10
leolandotan commentedComment #11
leolandotan commentedHere I have attached the patch and screenshot containing some new changes in the markup based from the previous one in 8.0.x. I also followed the Re-rolling patches guide.
This is the screenshot of the output after applying the re-rolled patch:

The commit that worked was from January 5, 2016 using `git log -1 --before="January 5, 2016"` and the commit hash is 425d682aa6a6b97e42f15813885ad0603b018a37. I have also tried to apply it in 8.1.x and 8.2.x branches and all worked.
Hope everything are in order.
Thanks!
Comment #12
daffie commentedTwo small remarks about your patch:
I think that you forgot to remove these lines.
And why did you change the description line?
Comment #13
daffie commented@leolando.lan: Can you create an interdiff.txt file for me. Makes reviewing your patch easier.
Comment #14
leolandotan commented@daffie thanks for the initial review. I think I missed this and will definitely look into this and get back to you asap.
Comment #15
leolandotan commentedHere I have created a new patch and looked into the details of applying the patch more carefully.
Conflict
Patch and Interdiff creation
I'm not sure on this part because there are other files changes from Jan 5 and the present rebased branch which I don't know how to remove. I just didn't include it. I would need guidance on this part its really required.
Hope everything is in order.
Thanks!
Comment #16
daffie commentedIt all looks good to me.
The patch fixes the invalid markup.
Comment #17
star-szrThanks everyone for the work on this so far. I don't know the correct fix but what is being proposed here seems problematic to me. The patch is moving the prefixing and suffixing to the child elements that are first and last which seems rather fragile.
Comment #18
leolandotan commentedHow about instead of creating manual HTML wrappers, we:
So the second form api wrapper would replace the container-inline div and we womt be breaking up the opening and closing divs to the prefix and suffix of the form items.
I'll try to do this.
Comment #19
leolandotan commentedHi @Cottser or anyone,
Proposed solution
Use a container form element to wrap the x and y fields.
Editor before and after screenshots
Before


After
Image field settings before and after screenshots
Before


After
Things done
SimpleTest Result for the Editor module
Hope everything is in order.
Thanks!
Comment #22
twistor commentedShould set
'#parents' => ['max_dimensions', 'width']here and inImageItem. That will simplify the patch a lot, and fix the tests.Comment #23
leolandotan commentedAh! Thanks @twistor! I'll try to apply your recommendation. I've been trying to work on this but I'm quite noob still on configurations and testings.
Comment #24
leolandotan commentedHere are the initial changes that @twistor has recommended.
Current issue
As I was testing the fields, I noticed that on the Text Format's Maximum Dimensions width and height field values doesn't get saved. I'm not sure on what's wrong but it might be the
#parentsattribute isn't being "respected" when saving the values for the Editor module?Any thoughts or help would be very appreciated.
Thanks!
Comment #29
mile23This issue blocks #2441373: Upgrade tests to HTML5 which in turn blocks #2441811: Upgrade filter system to HTML5 and #1333730: [Meta] PHP DOM (libxml2) misinterprets HTML5
Comment #31
huzookaThis is not just about cases when there is a block-level tag in
#field_prefixor#field_suffix.Every case affected when
#field_prefixcontains any kind of(...and this is true for
#field_suffixtoo.)Check this example in Views module's PathPluginBase.php:
I'd bet that here the developer assumed that the textfield
<input />will be wrapped by the<span dir="ltr">tag.I'm really just guessing that the expected output is something like this:
What actually happens there:
<span dir="ltr">get's closed right after the url, so<input />will be the child of the prefix wrapper span;So the output will be:
And this happens even if
Systemmodule's,StableorClassy'sform-element.html.twigtemplate is used.I'm sure that we have to make a decision. These are out options IMHO:
#field_prefixand#field_suffixand document that they cannot contain them (possibly a BC break?)<span class="field-prefix"/>and<span class="field-suffix"/>anymore (template change; definitely BC break, lower markup semantics)#field_prefixand#field_suffixcontains widow or orphan tags and conditionally output wrapper spans (at least template change; definitely BC break)Comment #36
catchThis is blocking #2441373: Upgrade tests to HTML5 which in turn blocks another major bug (and even another bug behind that one), so bumping to major.
If this is viable it seems like a good option, and it's not a bc break just a documentation of existing behaviour.
#2667340-19: Usage of field_prefix and container-inline creates invalid markup. #2 might be acceptable despite the markup change, if it's the only way to fix the bug.
Comment #37
jibranI was about to reroll the patch to get started on the issue but this bug has been fixed in #3072752: Invalid markup in ImageItem (causes test failures with symfony/dom-crawler:4.3+). We can close this as a duplicate now.