Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Theres no need for the div inside of forms - Drupal8 is html5 and not html 4
Proposed resolution
change form.html.twig :
From
<form{{ attributes }}><div>{{ children }}</div></form>
to
<form{{ attributes }}>
{{ children }}
</form>
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#3 | form-div-2250381-4.patch | 1.2 KB | mortendk |
form-inner-div.patch | 394 bytes | mortendk | |
Comments
Comment #1
ParisLiakos CreditAttribution: ParisLiakos commentedyes plz:)
Comment #3
mortendk CreditAttribution: mortendk commentedfixed the test
Comment #4
dawehnerWhat a nice and simple patch!
Couldn't find any used css for that
Comment #5
dawehnermoe
Comment #6
catchCommitted/pushed to 8.x, thanks!
Comment #8
tim.plunkettDid anyone check for when that div was added and why?
I thought it was needed for AJAX stuff, but it goes back to at least 4.7
As far as I can see that was removed with regard to CSS, but had no manual testing or thought for JS.
Comment #9
tim.plunkettFrom ajax.js, Drupal.AjaxCommands.prototype.insert:
Comment #10
joelpittetI did, the reason it was in there was for XHTML compliance. Going to look for issue... brb
Comment #11
joelpittetI think this was the reference I was thinking about.
https://drupal.org/node/1822210
Which @jwilson3 pointed out in #1822210-7: Investigate removing the inner div in form.html.twig
And a previous removal attempt here: #495480: Add class to wrapper div of form elements theme_form()
@tim.plunkett I can't see the correlation in that massive ajax comment to removing a div from form, can you break out the part that relates to this?
Comment #12
mortendk CreditAttribution: mortendk commentedoooh that was my first real try to help out with the markup in drupalcore *gets all sobby*
Anyhow i seems to fail in my javascript & prototype.insert knowledge of to get why a form div should be there?
Comment #14
tomogden CreditAttribution: tomogden commentedI would love to see this backported to D7.
Comment #15
joelpittet@tomogden me too, but I doubt that would happen as people may have styled against that or worse written JS DOM traversal.
Though you can do what I do, override the theme function:
And maybe @mortendk will be bold and add it to his base theme;)